这样不能通过编译。 const T& operator(const T& t);
必须这样才行 T& operator(const T& t);
难道会有这样的操作吗: T a,b,c; (a=b)=c;
这样不能通过编译。 const T& operator(const T& t);
必须这样才行 T& operator(const T& t);
难道会有这样的操作吗: T a,b,c; (a=b)=c;
1
mooyo Oct 17, 2019
T d = (a = b);
d = c; |
2
across Oct 17, 2019 大声告诉我, = 的意义是什么,const 的意义又是什么?
|
3
wutiantong Oct 17, 2019
会有。
运算符重载的函数声明都是有规范的,不要自己想当然。 |
4
koebehshian Oct 17, 2019
赋值运算符,左边的操作数,必须是的左值 https://en.cppreference.com/w/cpp/language/rule_of_three
|
5
zjsxwc Oct 17, 2019
既想赋值修改,又想 const 不得修改,你到底是想修改还是不想修改?
|
6
shfanzie Oct 17, 2019
2 楼 已结贴
|
7
ipwx Oct 17, 2019 via Android
T& t = (a = b); t = c;
|