+ 1
How to initialize data members using a constructor in a c++ program?
if the constructor is initialized within public of a class and the input of data members of the class is being done at the main function. what is the right way to do it? an example with a program would be helpful.
5 Respuestas
+ 8
myClass(string newName) : name(newName) { }
is also acceptable.. (Using everything else from the example provided by luka)
+ 5
naww i like the () way it seems alot cleaner... dang standards lol
+ 4
in c++11 we use these {} for initialising, but it's also okay to use (), tho it's not standard anymore
+ 3
thanks everyone for helping out.