Doubt in default constructor

Hi everybody,

I have started studying thinking in c++ , in the chapter "Initialization and cleanup" I have doubt .The author says "you might be thinking the compiler default constructor does some intelligent work like setting all the memory for the objects to zero, but it is not so." My doubt is I used to think the compiler default constructor provides initialization like it will set all the data members to zero I mean if they are of integer value. Then what exactly it does?
Then what exactly it does?
All available default constructors of the member variables are called.

The author is right: The default constructor of primitive (or POD = plain old data) types will not be called.

it initialises the variables yes, but you can't guarantee to what values, which is why you should always initialise them yourself to known values.
then what good does it do? I mean it's like providing them with some garbage value by not initializing them
It is good especially for larger objects, which are going to be initialized with useful values before use anyway. For example, if you allocated an array with a very large number of elements, wouldn't it be much more efficient to simply set the values to the useful data (ignoring the old garbage values) rather than zeroing it out and then setting the data (ignoring the 0's)?
Topic archived. No new replies allowed.