I have tried to solve an exercise, because i want to make sure if i've understand what i've learned.
I hope that you can let me know if thier is any mistakes, and i will try to solve it.
Consider the following definition of the class Employee:
string * firstName;
string * lastName;
static int empCount;
Employee(string first, string last);
static int getEmpCount();
static int counting;
Write the definition of the constructor function Employee(string first, string
last); which dynamically allocates memory for firstName and lastName and copies first
and last to them. The function should increment empCount by 1. Use deep copy.
Employee :: Employee(string first, string last)
Write the definition of the function ~Employee() which deallocates the dynamic memory and
decrease the value of empCount by 1.
Employee :: ~ Employee()
Write the definition the function getEmpCount() which returns the value of empCount.
int Employee:: getempCount()
In the main function add statements to do the following:
· Using the following declarations: string first=”Hilary”, last=”Sam”, create an object of
type class Employee named xEmp.
· Increment the value of counting in xEmp by 1.
· Print the value of empCount.