0

can someone solve my problem, please....

https://code.sololearn.com/cRmVZ37u8M49/#cpp

3rd Nov 2017, 9:29 AM
chee wai david wong
chee wai david wong - avatar
2 ответов
+ 3
#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; }; class Characteristic { public: Characteristic (string x) : characteristic(x) { } void printcha() { cout << characteristic << endl; } private: string characteristic; }; class Person { public: Person(string n, Birthday b, Characteristic x ) : name(n), bd(b), cha(x) { } void printInfo() { cout << name << endl; bd.printDate(); cha.printcha(); } private: string name; Birthday bd; Characteristic cha; }; int main() { Birthday bd(03,04,1997); Characteristic cha("LeaveMeAlone"); Person p("David", bd, cha); p.printInfo(); }
3rd Nov 2017, 10:33 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
Line 20: Constructor must have same name as class, make it uppercase -> Characteristic(){} Line 33, 45, 50: Here you want to access the class, and your classes name is uppercase again -> Characteristic Line 50: Characteristic's constructor takes a <string> as an argument, so LeaveMeAlone needs to be in double quotation marks so compiler recognizes it as a string -> "LeaveMeAlone" Line 50: Missing semicolon at the end of the line!
3rd Nov 2017, 10:35 AM
Shadow
Shadow - avatar