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 {
private:
Internal data;
public:
CReference () {}
~CReference (){}
};
class Internal {
public:
Internal () {}
~Internal () {}
};
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.
Forward declaration only allows you to use pointers and references to it, until full declaration is available
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With