why a syntax error

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class Birthdate { // the nested class 
private:
		int month;		int day;		int year;
public:
		Birthdate(int m=0, int d=0, int y=0) 
		{setData(m,d,y); cout << "Constructor for nested class!\n";}
		int getDay(void) const {return day;}
	void setData(int m, int d, int y) {month = m; day = d; year = y;}
		int zz;
	~Birthdate(void) {cout << "Destructor for nested class!\n";}
};
class Person { // the outer class
private:
	Birthdate bdate1;		int psuid;
public:
	Birthdate bdate2;
	Person(int ps, int m, int d, int y) : bdate1(m,d,y),bdate2(m,d,y) 
{setData(ps); cout << "Constructor for outer class\n";}
	void setData(int ps) {psuid=ps;}
	// int dbogus1(void) {return bdate1.day;}
	int dbogus2(void) {return bdate1.zz;}
	int dbogus3(void) {return bdate1.getDay();}
	~Person(void) {cout << "Destructor for outer class!\n";}
};

int main(void) {
		Person bob(3251,9,3,1965);
	//	Person matt;   // syntax error – why?
		Birthdate bdate3;   // NOT a syntax error
		cout << bob.bdate2.zz << endl;
	//5	cout << bob.bdate1.zz << endl;   // syntax error – why?
	//6	cout << bob.bdate1.day << endl;   // syntax error – why?
	//7	cout << bob.bdate1.getDay() << endl;   // syntax error – why?
		cout << bob.bdate2.getDay() << endl;
		cout << bob.dbogus2() << endl;
}


why Person matt gives a syntax error?
Last edited on
Person does not have a default constructor.
Topic archived. No new replies allowed.