Can someone explain - why list initializers are used as variables in private access specifier. Why variable m becomes month m ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can someone explain - why list initializers are used as variables in private access specifier. Why variable m becomes month m ?

#include <iostream> using namespace std; 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; };

12th Feb 2017, 1:57 PM
Black Temple
Black Temple - avatar
1 Answer
0
int m, int d, int y is reffered as month(m), day(d),year(y) during initialization and i cannot understand why? Is variable 'm' being assigned to month variable and so on?
12th Feb 2017, 2:00 PM
Black Temple
Black Temple - avatar