to purefan: ahaha, you helping me is more than enough :). You volunteered, I imagine full professional solution and help would require payment.
It works! I changed it a bit though.
Because our lecturer discourage us on writing member function straight inside the class( even warned us of getting zero marks if we ever do our lab sessions like that), so, instead of writing
'void setName (string sName) {name= sName} straight inside the class like yours, I am required to declare the member function like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
class Person
{
public: // contstructor and member function declarations//
Person();
Person (string pname, int page);
string get_name() const;
int get_age() const;
void setName(string sName);
private: //data fields//
string name;
int age; /*0 if unknown*/
};
|
then below it I add a member function set like this:
1 2 3 4 5
|
void Person::setName(string sName)
{
name = sName;
}
|
Then, below PEmployee, I wrote like yours.
And now, the output is:
Patrick earns a salary of 1000 |
Now, I can rest a bit from programming and focus on other subjects for the night. I still need to practice my Calculus and Database System @.@ Can't try to excel in Programming but fail in other subject ^_^.
Thank you!!! :D