Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualNausea

Posted 01 March 2013 - 10:03 AM

CHealthBar HealthBar;

 

That is your problem.

 

 

When using a forward declaration, you can only use a POINTER to the object, you cant actually declare an instance, as the compiler has no idea of the actual composition and size of a forward declared class.

 

Change CHealthBar to a reference or pointer, and your code should work.

 

 

EDIT: This StackOverflow answer explains it in a bit more detail.  So either change it so CEntity is aware of CHealthBar, or if you are going to continue using a forward declaration, make CHealthBar in CEntity a pointer or reference.

Ok, thank you. Will try to get that up and running then.

Yep got it working, thank you :)


#1Nausea

Posted 01 March 2013 - 09:49 AM

CHealthBar HealthBar;

 

That is your problem.

 

 

When using a forward declaration, you can only use a POINTER to the object, you cant actually declare an instance, as the compiler has no idea of the actual composition and size of a forward declared class.

 

Change CHealthBar to a reference or pointer, and your code should work.

 

 

EDIT: This StackOverflow answer explains it in a bit more detail.  So either change it so CEntity is aware of CHealthBar, or if you are going to continue using a forward declaration, make CHealthBar in CEntity a pointer or reference.

Ok, thank you. Will try to get that up and running then.


PARTNERS