I have error C2079 on compiling following code and I dont understand why. class foo is declared later (forward declaration).
class foo;
//template <typename dataType>
class Toto
{
foo a; //C2079
};
class foo
{
public:
int x;
};
And what is really strange in that issue, is if I uncomment the "template line" (before class Toto declaration), the error disapear. I could use it as a workaround, but I don't understand what happen here.
Following first feedback I got, I tried the following code :
class foo;
//template <typename dataType>
class Toto
{
foo *a; // solve C2079
void otherFunc()
{
a->myFunc(); // C2027
}
};
class foo
{
public:
int x;
void myFunc()
{
};
};
So replacing "foo a" by a pointer "foo * a" solve the compilation error. But adding a function with it's implementation and calling "a->myFunc()" is now prroducing "error C2027: use of undefined type 'foo'". Is it similar issue ? And again "Template" solve it. And yes, I use MSVC compiler.