This class is written exactly as it is in the textbook

Write your question here.

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
 #include "person.h"
#include "dateType.h"
class personalInfo
{
public:
	void setpersonalInfo(string first, string last,
						 int month, int day,
						 int year, int ID);
 	//Function to set the personal information.
 	//Data members are set according to the parameters
 	//Postcondition: firstName = first;
 	//   lastName = last; dMonth = month;
 	//   dDay = day; dYear = year; personID = ID;

 	void printpersonalInfo() const;
 		//Function to print the personal information.
	personalInfoType(string first = " ", string last = " ",
					 int month = 1, int day = 1,
					 int year = 1900, int ID = 0);
		//constructor
		//Data members are set according to the parameters
		//Postcondition: firstName = first;
		//	 lastName = last; dMonth = month;
		//   dDay = day, dYear = year; personID = ID
private:
	personType name;
	dateType bDay;
	int personID;
};

when I compile I get this error:
C:\Martin\MalikChapter2\clockInheritance\person\personalIntoType.cpp:19:34: error: ISO C++ forbids declaration of 'personalInfoType' with no type [-fpermissive]

please help
Your constructor should have EXACTLY the same name as the class.
personalInfoType
is NOT the same as
personalInfo
This class is written exactly as it is in the textbook

What book & edition? This book has it correct:
https://books.google.com/books?id=LAU-BKWYdFYC&pg=PA83&lpg=PA83&dq=%22personalInfoType%22&source=bl&ots=fazkPbvl3b&sig=lFgPCUfk3_YIJspdlHFPlWU_vEk&hl=en&sa=X&ved=2ahUKEwiCiKvYnu3fAhUFh-AKHf-rC-wQ6AEwBXoECAkQAQ#v=onepage&q=%22personalInfoType%22&f=false
Data Structures Using C++
2nd Edition
D.S. Malik

If it's another book/edition, perhaps it's noted in errata. 1st edition maybe?
Last edited on
Thank you all!!!
I changed personalInfo to personalInfoType and the error disappeared.
Topic archived. No new replies allowed.