inheritance in classes, im not shur how to do this, please help.

here is what I did so far
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
#include <iostream>

using namespace std;

class Adress {
protected:
string name;
int age;
public:
void setAge (int a)
    { age=a;}
void setName (string a)
    { name=a;}
int getAge (){
       return age;
}
    string getName (){
       return name;
}


};
    
class People: public Adress {
protected:
int homeNumber;
  public:
void setHomeNumber (int a){
	homeNumber=a;
};
	int getHomeNumber(){
        return homeNumber;
	}
};

int main () {
  string name;
  People obj1, obj2;
  obg1.setHomeNumber (8);
  obj1.setAge (17);
  obj1.setName ("isaac");
  cout << obj1.getHomeNumber() << "\n";
  cout << obj1.getName() << "\n";
  cout << obj1.getAge() << "\n";
  system("pause");
}
Last edited on
Topic archived. No new replies allowed.