This code:
#include <iostream>
class Parent
{
int name;
class Child
{
int school;
void test()
{
std::cout << this->name;
}
};
};
int main(int argc, char *argv[])
{
Parent MyParent;
return 0;
}
Generates this error:
error: 'class Parent::Child' has no member named 'name'
Is there any way to allow a nested class to access members of its parent?
I have some code with two classes, A and B, that were both referencing varaiables like global.value defined in a global variable called "global". I moved these variables into A and also made B a member of A, but found that B can't access A's members. Is there any way to do this without using 'static'?
Thanks,
Dave