c++运算符重载为何complex operator+(complex &a,complex &b)也对,complex operator+(complex &a)也对

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/27 05:20:12
c++运算符重载为何complexoperator+(complex&a,complex&b)也对,complexoperator+(complex&a)也对c++运算符重载为何complexoper

c++运算符重载为何complex operator+(complex &a,complex &b)也对,complex operator+(complex &a)也对
c++运算符重载为何complex operator+(complex &a,complex &b)也对,complex operator+(complex &a)也对

c++运算符重载为何complex operator+(complex &a,complex &b)也对,complex operator+(complex &a)也对
complex i,j,k;
k = i + j;
如果你的重载函数作为complex类的成员函数,调用的的就是complex operator+(complex &a)
如果的重载函数作为类的友元函数,调用的就是complex operator+(complex &a,complex &b)