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;}

It works the other way around, too:

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

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: