Sign in to follow this  

Defining nested class separately

Recommended Posts

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...

class A
class B;
B *b;
int foo();

class A::B
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 =;

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this