Hi,
I am looking at some code that has a class called sample that has as a private member an instance of class digitalSample called digData.
the code for the sample default constructor is
sample::sample():digData(0){...contents etc .....}
I read this as the sample default constructor explicitly calling the digData general constructor.
My question is why is the code written this way??? Why not simply write
sample::sample{ digData(0)}
that is putting the digData contructor call in the body of the sample constructor.
Is it just convention or is it to ensure digData constructor gets called first???
I am looking at some code that has a class called sample that has as a private member an instance of class digitalSample called digData.
the code for the sample default constructor is
sample::sample():digData(0){...contents etc .....}
I read this as the sample default constructor explicitly calling the digData general constructor.
My question is why is the code written this way??? Why not simply write
sample::sample{ digData(0)}
that is putting the digData contructor call in the body of the sample constructor.
Is it just convention or is it to ensure digData constructor gets called first???