On a slightly different thread, I remember seeing some Microsoft
COM code which played games with nested classes by doing some
pointer arithmetic with "this". My recollection is a
bit fuzzy, but I seem to remember the nested class was able to access
private data in the parent. Is this just pure evil, or is there a standard
compliant way of doing this? It would seem to be a useful mechanism
to break up the functionality of the parent class by using nested classes
each specialized in one particular behavior/functionality.
dave
"newbiecpp" <ne*******@yahoo.com> wrote in message
news:qNLTc.13899$ZY3.6813@trndny08...
Why this code cannot be compiled (under VC++ 7.0):
class Outer {
public:
class Inner {
public:
Inner() : in_data(0) {}
void action()
{
Outer::out_data++; // illegal reference to non-static
member 'Outer::out_data'
}
int in_data;
};
Outer() : out_data(0) {}
void action()
{
Inner::in_data++; // ittlegal reference to non-static
member 'Outer::Inner::in_data'
}
int out_data;
};
Thanks in advance!