C++ "?>"运算符
C++ "?>" operator
谁能给我解释一下这种操作符
这是什么?>在c++中做什么?
使用它的代码示例:
#include <iostream>
#include <string>
using namespace std;
class A {
public:
int x;
};
class B : public A {
public:
B() {x=1;}
B(int x) {this?>x = x;}
};
int main()
{
B c1;
B c2(10);
cout << c1.x;
cout << c2.x;
return 0;
}
我认为你试图说->
,因为?>
不存在。
在上下文中,我确定您想要->
。
你可能在打字的时候出错了。PD:尝试编译前问
这是一个打字错误。你可能想参考->
。this
操作符用于访问调用该函数的对象的属性,->
操作符用于访问该对象的属性。
相关文章:
- 为什么比较运算符如此快速
- C++映射:具有自定义类的运算符[]不起作用(总是返回0)
- 使用C++中的模板和运算符重载执行矩阵运算
- 为什么这个运算符<重载函数对 STL 算法不可见?
- 增量运算符与后缀混淆
- 一个关于在C++中重载布尔运算符的问题
- 运算符C++ "delete []"仅删除 2 个前值
- 模板类无法识别友元运算符
- 我可以使用条件运算符初始化C风格的字符串文字吗
- 关闭||运算符优化
- 通过继承类使用来自不同命名空间的运算符
- C++Cast运算符过载
- 如何使用AngelScript注册SFML Vector2运算符
- 重载元组索引运算符-C++
- 如何使用重载的相等(==)运算符向测试用例添加描述
- 为什么Mat类的两个对象可以在不重载运算符+的情况下添加
- 多个If语句与使用逻辑运算符计算条件的单个语句的比较
- 布尔比较运算符是如何在C++中工作的
- 重载运算符new[]的行为取决于析构函数
- 是否需要使用 - &gt;运算符在C 中调用成员函数时