有——
C_Type.h
#ifndef C_TYPE_H
#define C_TYPE_H
template <class T>
class C_Type {
public:
T m_val;
// implementation ...
};
#endif
还有一个程序——
#include <iostream>
#include <typeinfo>
#include "C_Type.h"
using namespace std ;
int main () {
C_Type<int> a ;
cout <<typeid(a.m_val).name()<<endl;
}
我试图提取int
其中的C_Type<int>
组成部分,上面的程序只是给出了输出 - i
。
编辑 :
是否可以在不考虑类成员(即)的情况下获得类型(即 int 或 i m_val
)?