inheritance issue

OK, I have beat myself to death on this. I know it's something easy I'm missing. This is part of a 8 class program that makes up an address book. Classes are personType, dateType, addressType. Those classes are supposed to be inherited in to extPersonType. (extPersonType subClass, personType superClass). I am only trying to get extPersonType to inherit personType, then do the same for the other classes. I am getting errors: C2504: 'personType' base class undefined, firstName
undeclared identifer, lastName undeclared identifer, C2614 'extPersonType' illegal
member intialzation: 'personType' is not a base member. All that said, yes extPersonType is the sub and "should" inherit personType. That is my goal. Any thoughts on what I am doing wrong?
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using namespace std;
#ifndef PERSONTYPE_H
#define PERSONTYPE_H
class personType{

protected:
	string firstName;
	string lastName;
public:
    void print()const;
	void setName(string first, string last);
	string getFirstName()const;
	string getLastName()const;
	personType(string first = "", string last = "");
	/*personType();*/
};
#endif

#include <string>
#include <iostream>
#include "personType.h"
using namespace std;


void personType::print()const{
	cout << endl;
	cout << firstName << " " << lastName << endl;
}
void personType::setName(string first, string last){

	firstName = first;
	lastName = last;
}
string personType::getFirstName()const{

	return firstName;
}
string personType::getLastName()const{

	return lastName;
}
personType::personType(string first,string last){

	firstName = first;
	lastName = last;
}
//personType::personType(){
//
//	firstName = "";
//	lastName = "";
//}

using namespace std;


class extPersonType:public personType{/*, public dateType, public addressType*/

private:
	string relation;
	string phone;
public:
	void print()const;
	void setRelation(string phone, string extRelation);
	void setPhone(string extPhone);
	void setRelation(string extRelation);
	string getRelation()const;
	string getPhone()const;
	extPersonType(string relation = "",string phone = "");
	/*extPersonType();*/
};

#include <string>
#include <iostream>
#include "extPersonType.h"
#include "personType.h"
//#include "dateType.h"
//#include "addressType.h"
using namespace std;

//this is where I am trying to fix the problem. Inheriting here...
void extPersonType::print()const{

	cout << relation <<  " " << phone  << endl;
}
void extPersonType::setRelation(string extRelation){
	relation = extRelation;
}
void extPersonType::setPhone(string extPhone){
	phone = extPhone;
}
string extPersonType::getRelation()const{

	return relation;
}
string extPersonType::getPhone()const{

	return phone;
}
extPersonType::extPersonType(string extRelation, string extPhone)
:personType(firstName,lastName) {

	relation = extRelation;
	phone = extPhone;
}
////extPersonType::extPersonType():personType()/*:dateType():addressType()*/{ //maybe the same here :personType(...):addressType(...)
////
////	relation = "";
////	phone = "";
////}
I suppose that you just paste all the files together.
Are you including string in persontype.h ?
Does extendperson include persontype.h ?

What is the purpose of all that getter setter, that just act as if your members were public.
yes including string in my class implementation files. headers I don't think needs it. That's what the book shows. And the setter/getter is just setting the input values passed from main() as follows;
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
37
38
39
40
#include <fstream>
#include <iostream>
#include <string>
#include "personType.h"
#include "addressType.h"
#include "extPersonType.h"
#include "dateType.h"
using namespace std;

int main(){

	//ofstream file;
	//file.open("MyTxT.txt");
	
	cout << "******************    Welcome to your address book.    ***********************\n" << endl;
	/*int month = 0,
		day = 0,
		year = 0,
        input = 0,
		x;*/
		             // make it an array 0f 500.
        string first,last;/*,street,city,state,zip,relation,phoneNum;*/
	//char choice;

	extPersonType myExt;
    //personType myPerson;


			cout << "Enter the first name: ";
			getline(cin,first);
            cout << "Enter the last name: ";
		    getline(cin,last);
			myExt.setName(first,last);
		

//cin.sync();  
//cin.peek();  

// 
};

input for first name and last name should be pasted to extPersonType using the inherited personType that is already defined. This is my overall goal any way.
Headers do need includes. If you just use references or pointers you can forward declare. (but the compiler needs to know what is the type of the variables)

For what your setter do, you could simply make your attributes public:
1
2
3
extPersonType myExt;
getline(cin, myExt.firstName);
getline(cin, myExt.lastName);
Topic archived. No new replies allowed.