Defining nested class separately
Is it possible to define a subclass outside the main class?
Something like:
class A {
class B;
};
class A::B {
};
The fastest way to see if this would work is to try it for yourself.
But yes, you can do this as long as you don't try to use the incomplete type improperly before you fully define it...
But yes, you can do this as long as you don't try to use the incomplete type improperly before you fully define it...
class A{ class B; B *b;public: int foo();};class A::B{public: int x, y;};int A::foo(){ b = new B(); // stupid example, whatever... return b->x * b->y;}int main( int arg, char **argv ){ A a; int x = a.foo();}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement