Class Instantiation

Hi all, just a general question I have.

If I create a class with my data members containing other class objects I created in my project.

Can I just declare them in the class and when I instantiate an instance of the class they will be created???

I know with pointers you should initialize them with NULL in the class's constructor....but how bout OBJECTS that I define as members...

Will the Objects default constructor be called automatically to create the instance of the data member object in my class that I instantiated?

Basically that is my main concern, will my classes data members which our objects...be created automatically when I instantiate an instance of the class by the data members default being called automatically....OR DO I need to call the data members constructor explicitly in my classes constructor???

Thanks for the help!!!



Will the Objects default constructor be called automatically to create the instance of the data member object in my class that I instantiated?


Yes. Default constructors are always run by default unless you explicitly call a different ctor.
Topic archived. No new replies allowed.