An inheritance issue.

I have derived two classes (employee and client) from a base class (person, containing members lastName and firstName and functions string getlastName void setlastName). My goal is to be able to modify an employees name using the functions from base class. i.e.
class person
{
getname;
setname();
cout<<"input name"<<endl;
cin>>name;
}
class employee : public person
void Employee::newEmployee()
{
setname; //here is where I am trying to modify the attribute name, using functions from the base class.
}
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
class person
{
public:
  string lastName, firstName;
  string getname();
  void setname();
};


void person::setname()
{
  cin >> firstName;
  cin >> lastName;
}

string person::getname()
{
  return firstName;
}

class employee : public person
{};

int main()
{
  employee a;
  a.setname();
  cout << a.getname();
}

It's not an inheritance; your function declaration syntax is just completely off.

Look at how Moschops added get/setname.
Topic archived. No new replies allowed.