0

Member Intializers

Guys, can anyone re-explain this chapter? I've taken the C++ course, but I still don't understand about member intializers chapter.

25th Dec 2017, 2:30 AM
kelly k audrey
kelly k audrey - avatar
2 odpowiedzi
+ 3
Imagine that you want to have a constant variable in your class. and there is a rule: constant variables must have value from the time they are created. but when is the begining of their life? you can say it's the time that the class constructor is called. we can't do our initialization for our constant variable even inside constructor because that time our class have been created! so c++ gives us this chance to do such initialization in a special way; by using ":" after constructor function and before starting of it's brackets and then writing our initialization list. Hope it would be helpful 😅
31st Dec 2017, 9:27 PM
S.Mary.Gh
S.Mary.Gh - avatar
+ 1
thank you very much @S.Mary.Gh
1st Jan 2018, 2:45 AM
kelly k audrey
kelly k audrey - avatar