Your understanding seems right.
You have to include the header whenever the compiler needs the definition of the class. If there is just a pointer or reference, it doesn't need to know anything about the class. If you have an object like in your example, it needs the definition of the class to know its size and possibly to be able to call its constructors and destructors in the outer class's default constructors and destructor.
Another time the header needs to be included is if you have member functions defined inline in the class definition. So in this case you would need to include the header (although a better solution might be to move the function definition to the source file):
Code:
class someclass {
someobject* pobj;
void doit()
{
if (pobj)
pobj->foo();
}
};
In that case the compiler needs the definition of someobject to verify that foo() is an actual member function.