C ++:赋值运算符的名称是什么,它采用不同的数据类型

时间:2015-05-26 11:12:49

标签: c++

我很困惑,不记得类的赋值运算符的名称,它采用的数据类型与当前类的const&不同...

这样:

struct Thing 
{
    Thing& operator = (const Thing& other); // This is Assignment Operator

    Thing& operator = (int xyz); // What is the name of this?

    // really not needed here, just to exemplify that this class has an int
    int memberStuff;
};

那么,问题是:Thing& operator = (int xyz);的成员struct Thing的名称是什么?是赋值运算符还是别的什么?

1 个答案:

答案 0 :(得分:4)

两者都是作业。

唯一的事情是第一个(引用同一个类的对象)可以被称为 copy 赋值运算符,而另一个只是一个普通的赋值运算符。