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.
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 😅
+ 1
thank you very much @S.Mary.Gh