• Advertisement
Sign in to follow this  

Simple question about constructors

This topic is 4582 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Little embaressed to be asking this :P but, if I call
Sprite Me;
Will the constructor
Sprite::Sprite(void){}
be called?

Share this post


Link to post
Share on other sites
Advertisement
and when it isn't that syntax is illegal. In C++ a constructor is ALWAYS called. Sure it might be a default constructor that is optimized away but that's just a minor detail.

Share this post


Link to post
Share on other sites
yes, the best way to see this is to put cout << "const called" <<endl; in the constructor

then something like

void main()
{

cTest testClass;

}

will produce....

const called

in console

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement