devxlogo

Forward Declaration of Classes and Structs

Forward Declaration of Classes and Structs

You can use the keywords class and struct in forward declarations interchangeably. For example:

 class X; // fwd declaration uses 'class'X *p;struct X // definition uses 'struct'{};void f(){ p=new X;}

size=3>
It works the other way around, too:

 struct X; X *p;class X {};

size=3>

devx-admin

Share the Post: