Apr 16, 2010 at 5:49am UTC
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 Apr 16, 2010 at 6:05am UTC
Apr 16, 2010 at 5:57am UTC
Why exactly does EmployeeHousing derive from Employee? It isn't an employee...
Apr 16, 2010 at 8:57am UTC
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.
Apr 18, 2010 at 2:20am UTC
should the ":Employee " be in small e or captial e becos i got it to work in small e but not in captial e...