Q:

Can a nested class have a member pointer to the outer class?

In C++, given a nested class, can inner class have a member pointer to the outer class?
class Outer{
public:
    class Inner{
    public:
        int i;
        Outer *ptr;

        Inner(){
            i =0;
            ptr = NULL;
            ....
        }
        ...

    };
}

If it is OK, are there anything/tricky issues that should be careful and cautious?

A:

You can declare a pointer or reference to the outer class since it doesn't require a complete type. Declaring an object would instead require the type to be complete. See reference on incomplete types
This is the same reason why you can have a pointer to the same class as a data member:
class Outer
{
  Outer* p; // Outer is an incomplete type at this point
};

