Pointer to incomplete class type is not allowed

no if he do not give name for that variable sigh… :smiley:

this will not work class UBoxComponent; inside the class

this will work class UBoxComponent YOURVARIABLENAME;* inside the class

@up

sry i missunderstod… http://jatinganhotra.com/blog/2012/11/25/forward-class-declaration-in-c-plus-plus/

because if you do that with a simple class xyclass and close with ; inside your class - that will be member instead of declaration and compiler try to understand as class member and will throw compile error… because

  1. there is no member name
  2. compile do not recognize class.

with usage of class xyclass pointertoclass;* you create an incomplete class pointer and compile knows that pointer is a forward declared and will not throw any error…

basically

class xyclass;

class yourclass
{
    xyclass* pointer;
}

same with

class yourclass
{
   class xyclass* pointer;
}

compiler understand both case, since class member pointing to class which is not included. :slight_smile: