C++ | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

C++

lass MyClass { public: int var; MyClass() {} MyClass(int a) : var(a) { } }; in this class when we overload is the writting of int var ; important or not if we dont write what will happen .

20th Jun 2018, 5:15 AM
Jamaluddin Huseinkhail
Jamaluddin Huseinkhail - avatar
2 ответов
0
That style of writing variable after colon in constructors is called initializer list. If don't write it then nothing will happen. You will just need to add the variable assignment code in the constructors body.
20th Jun 2018, 7:19 AM
Prateek Vishwakarma
Prateek Vishwakarma - avatar