Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


#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