Is there a way to get the type of the class from an instance of the object from the same class? Like that:
template <class T>
class A {
public:
static int value;
using ClassType = A<T>;
auto getSelfType(){
return ClassType;
}
};
int main(int argc, char** argv){
A<int> j;
j.getSelfType()::value = 12;
return 0;
}
1
It seem you want to declare a variable of the same type. In that case use decltype
:
A<int> a;
decltype(a) b; // same as: A<int> b;