Class construction with initial values

后端 未结 8 1889
别那么骄傲
别那么骄傲 2020-12-06 20:05

I\'m new to C++, and the whole idea of classes - I\'m still reading a book to try and learn. The book I\'m reading says that when I construct a class, I can assign default v

8条回答
  •  再見小時候
    2020-12-06 20:15

    I would get into the habit of using initialisation lists. They will not suffer from problems when somebody changes a char to some object where the default constructor is called first, and also for const correctness for the const values!

提交回复
热议问题