+ 2

What does the colon operator do here?

In the birthday program class Birthday { public: Birthday(int m, int d, int y) : month(m), day(d), year(y) { } void printDate() { cout<<month<<"/"<<day <<"/"<<year<<endl; } private: int month; int day; int year; };

3rd Feb 2018, 3:47 AM
Ravi bharathi. T. S
Ravi bharathi. T. S - avatar
3 Antworten
+ 1
this colon operator is used here in member intializer list . for more on member intializer list check out this https://www.geeksforgeeks.org/when-do-we-use-initializer-list-in-c/
3rd Feb 2018, 7:43 PM
Bhavya Sharma
Bhavya Sharma - avatar
+ 16
I think u forgot to make your birthday program public or provide us the link so we can try telling what colon operator do there
3rd Feb 2018, 5:00 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 7
Where’s the birthday program post code plz
3rd Feb 2018, 3:54 AM
Ole113
Ole113 - avatar