k im feeling a little generous today so i will show you how to build your employ class
Code:
#include<cstring>
using namespace std;
class Employ
{
private: float Salary;
char* Name;
public: Employ();
Employ(float,char*);
Employ (const Employ&);
virtual ~Employ();
Employ& operator =(const Employ&);
const char* GetName()const {return Name;}
const float GetSalary()const {return Salary;}
};
Employ::Employ()
{
Name=new char[1];// make room for the null byte
if(Name) *Name='\0';// add null byte if new was successful
Salary=0.0;
}
Employ::Employ(float Sal,char* N)
{
Name=new char[strlen(N)+1];
if(Name) strcpy(Name,N);
Salary=Sal;
}
Employ::Employ(const Employ& E)
{
Name=new char[strlen (E.GetName())+1];
if (Name) strcpy(Name,E.GetName());
Salary=E.GetSalary();
}
virtual Employ::~Employ()
{
if (Name) delete[] Name;
}
Employ& Employ::operator =(const Employ& rhs)
{
if (this==&rhs) return *this;
if(Name) delete[] Name;
Name=new char [strlen (rhs.GetName())+1];
if (Name) strcpy(Name,rhs.GetName());
Salary=rhs.GetSalary;
return *this;
}
That gives you a small framework from which to continue building. Make Calc.Salary a virtual function of Employ and override it in the derived classes.