You see, i like structs, so i put some structs inside structs and try to use these nested structs in a class template to declare some variables. The only problem is: it just doesn't seem to work as expected. This is my minimal example code:
#include "stdafx.h"
#include <iostream>
struct T1
{
struct NESTED
{
int var1 = 12345;
};
};
struct T2
{
struct NESTED
{
float var1 = 67890;
};
};
template <typename T > class Proletarian
{
public:
T * t; //works
//T::NESTED * tn; ****** doesn't work! *******
Proletarian<typename T>()
{
T::NESTED * tNested = new T::NESTED; //works
std::cout << tNested->var1;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
Proletarian<T1> t1 = Proletarian<T1>();
Proletarian<T2> t2 = Proletarian<T2>();
return 0;
}
I use Visual Studio 2013, Intellisense is ok with my code, but it just won't compile with these two errors:
[Line 20 Column 1] error C2143: syntax error : missing ';' before '*'
[Line 20 Column 1] error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
I'm not that good at C++, so probably don't quite understand how templates work and why this actually happens.