扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
int x, y, z; x = y = z = 15; // chain of assignments |
x = (y = (z = 15)); |
class Widget { public: ... Widget& operator=(const Widget& rhs) // return type is a reference to { // the current class ... return *this; // return the left-hand object } ... }; |
class Widget { public: ... Widget& operator+=(const Widget& rhs) // the convention applies to { // +=, -=, *=, etc. ... return *this; } Widget& operator=(int rhs) // it applies even if the { // operator’s parameter type ... // is unconventional return *this; } ... }; |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。