怎么写派生类的赋值构造函数啊
怎么写基类的析构函数,我错在哪!怎么写派生类的赋值构造函数,我错在哪里!
#include<string>
#include<iostream>
#include<cassert>
using namespace std;
class Employee
{private:
string name;
int ID;
public:
Employee(char* a, int b)
:name(a),ID(b)
{}
Employee (const Employee& s)
{
assert(this!=& s);
name=s.name;
ID=s.ID;}
Employee& operator=(const Employee& rhs)
{
assert(this!=&rhs);
name=rhs.name;
ID=rhs.ID;
return *this;
}
~Employee()
{
//这里怎么写析构函数。
}
};
class Manager:public Employee
{
private:
int sal;
public:
Manager(char*a, int b, int c)
:Employee(a,b),
sal(c)
{}
Manager(const Manager& s)
:Employee(s)
{ sal=s.sal;}
//这里怎么写赋值构造函数。下面的代码错在哪怎么修改啊!
//Manager& operator=(const Manager& rhs)
//:Employee(rhs)
//{ // ID=rhs.ID;
// name=rhs.name ;
// sal=rhs.sal;
// return *this;}
};
int main ()
{
Employee E("fuwei" ,236763612);
Manager F(" xiaoke", 236763613 , 5000);
E=F;
cin.get();}