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!


Class constructor and member constructors


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Tispe   Members   -  Reputation: 1047

Like
0Likes
Like

Posted 06 October 2012 - 12:13 PM

Hi

I have a class obejct "B" as a member variable within another class "A". Which constructor runs first, A or B?

The idea is that I need to init object B by passing down some information from A. I will leave the constructor of B blank and just call "B->init(pData)" from A's constructor.

Cheers

Sponsor:

#2 SiCrane   Moderators   -  Reputation: 9675

Like
2Likes
Like

Posted 06 October 2012 - 12:16 PM

B's constructor is run as part of A's constructor. As part of A's construction all base classes are constructed first, then all member variables in order of declaration and then the body of A's constructor is entered.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS