1.C++类默认函数 函数
class Empty
{
public:
Empty(); // 缺省构造函数
Empty( const Empty& ); // 拷贝构造函数
~Empty(); // 析构函数
Empty& operator=( const Empty& ); // 赋值运算符
Empty* operator&(); // 取址运算符
const Empty* operator&() const; // 取址运算符 const
}; this
2.子类的默认赋值函数会调用父类的赋值函数(重载了就调用重载的); spa
可举例证实; 继承
3.子类重载赋值函数时能够显示调用父类的赋值函数; class
CBaseTest1& CBaseTest1::operator=( const CBaseTest1& val_ )
{
this->CBaseTest::operator = (val_);//CBaseTest1为子类,显示调用父类 CBaseTest 的赋值函数方式 构造函数
k = val_.k; di
return *this;
} co
相似的其余继承且须要隐藏的重载运算符均可以显示进行调用父类相同的运算符,不须要知道父类的成员了。 background