CPlusPlusThings/practical_exercises/10_day_practice/day7/=号运算符/=例题.cpp
2023-01-02 20:39:00 +08:00

17 lines
334 B
C++

//例题ch.cppi
#include <iostream>
using namespace std;
class X{
public:
X &operator = (const X & x)
{cout << "a:"; return *this;};
};
int main ()
{
X obj1, obj2, obj3;
obj1 = obj2; //调用重载“=”
obj1.operator= (obj2); //调用重载“=”
obj1 = obj2 = obj3; //调用重载“=”
system("pause");
}