Topic on Inheritance

Hi there,

I would need to confirm a few basic concepts. I have a :

Base Class (Employee Class)
------------
(Protected)
string name
int id
____________
(Public)
Employee(string, int)
string getName()
int getID
-------------



Derived Class - (EmployeeHousing)
------------------------------------------
(Protected)
Employee employee
string address
string roomNum
___________________________________________
(Public)
EmployeeHousing(string, int, string, string)
string getEmployeeHousingDetails()
EmployeeHousing(string, int, string, string)
-------------------------------------------

I admit, my C++ knowledge is rather poor. I would like to know how I can do the coding for getEmployeeHousingDetails() and Employee employee.

EmployeeHousing::EmployeeHousing(string name, int id , string address, int roomNum) : Employee(name, id)
{
this->addr=address;
this->roomNum=roomNum;

}

Is the above implementation code correct?
Thanks for the help.



Last edited on
Why exactly does EmployeeHousing derive from Employee? It isn't an employee...
The syntax is correct for a constructor.

You don't need this-> to access addr or roomNum within a EmployeeHousing method as it's implied.
should the ":Employee " be in small e or captial e becos i got it to work in small e but not in captial e...
Topic archived. No new replies allowed.