采用不同数据类型的赋值操作符的名称是什么?



我很困惑,记不起一个类的赋值运算符的名字,它接受的数据类型与当前类的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的一个成员,它的名字是什么?是赋值运算符还是别的什么?

都是赋值。

唯一的问题是,第一个操作符(接受对同一类对象的引用)可以称为复制赋值操作符,而另一个操作符只是普通的赋值操作符。

最新更新