C++ – Forward Declaration of class in C++, incomplete type


I have an issue with Forward Declaration in C++ using clang compiler. Here is my code. It points data in CReference member as incomplete type.
Please Help

class Internal;

class CReference {
    Internal data;

    CReference () {}    
    ~CReference (){}

class Internal {
    Internal () {}
    ~Internal () {}

Best Solution

Forward declarations are useful when the compiler does not need the complete definition of the type. In other words, if you change your Internal data; to Internal* data or Internal& data, it will work.

Using Internal data;, the compiler needs to know the whole definition of Internal, to be able to create the structure of CReference class.