采用不同数据类型的赋值操作符的名称是什么?
C++: What is the name of the assignment operator which takes different data type
我很困惑,记不起一个类的赋值运算符的名字,它接受的数据类型与当前类的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
的一个成员,它的名字是什么?是赋值运算符还是别的什么?
都是赋值。
唯一的问题是,第一个操作符(接受对同一类对象的引用)可以称为复制赋值操作符,而另一个操作符只是普通的赋值操作符。
相关文章:
- C++ 指针赋值运算符重载(不仅是对象赋值,还有指针赋值)
- 如何在我自己的类 Vector 中使用 Move 构造函数而不是 Move 赋值运算符
- C++移动语义:为什么调用复制赋值运算符=(&)而不是移动赋值运算符=(&&)?
- 'explicit' g ++ 中的关键字对简单构造函数(不是复制/赋值构造函数)没有影响?
- 为什么具有const成员的结构是可赋值的
- c++中的重载赋值操作符
- c++类继承和赋值操作符
- 带引用类成员的赋值操作符
- 复制构造函数,赋值操作符重载
- 当类是子类时重载赋值操作符
- 赋值操作符的返回类型是什么?
- 在c++中使用赋值操作符而不是调用函数
- 为什么不是只有一个?复制构造函数和赋值操作符
- 标准库中自赋值不安全的move赋值操作符的基本原理是什么?
- 是此处使用的复制构造函数、赋值操作符或两者
- 如果在调用时没有取赋值操作符的返回类型,将会发生什么?
- 当我从赋值操作符返回值时,首先,调用复制构造函数的机制和基础是什么?
- 采用不同数据类型的赋值操作符的名称是什么?
- 重载赋值操作符和其他操作符的区别是什么?
- 我对这个赋值操作符错误的假设是正确的吗?