Why do bd is added to constructor in this code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why do bd is added to constructor in this code?

plsease help me out. I want to know what is the role of bd in the constructor I know how this code has printed date and name of the person. but why bd added to constructor and bd is assigned as value of bd in main function. Code is given.......... in this site https://code.sololearn.com/cZTTW211oOW2/?ref=app

29th Apr 2017, 9:00 AM
Harikrishnan s
Harikrishnan s - avatar
1 Answer
+ 5
1) Birthday(int m, int d, int y){.....} 2) Person(string n, Birthday b){.....} 3) Birthday bd(2, 21, 1985); 4) Person p("David", bd); notice line 2 Person constructor have a Birthday as a parameter that is the reason bd is passed along when creating the Person instance
29th Apr 2017, 9:04 AM
Burey
Burey - avatar