+ 1

What do you mean by colon operator(:)?

class MyClass { public: int var; MyClass() {} MyClass(int a) : var(a) { } //Why there is colon(:) in between constructor and class member? };

16th Mar 2018, 9:54 AM
Rahul Pathak
Rahul Pathak - avatar
2 Réponses
+ 2
It's called initializing list. It just initializes your "var" with value of "a".
16th Mar 2018, 10:15 AM
Jakub Stasiak
Jakub Stasiak - avatar
+ 1
thanks man.....👍👍👌
16th Mar 2018, 11:25 AM
Rahul Pathak
Rahul Pathak - avatar