下面程序中对一维坐标点类Point进行运算符重载#include <iostream>using namespace std;class Point{public: Point(int val) {x=val;} Point& operator ++(){x++;return *this;} Point operator ++(int) {Point old=*this;++(*this);return old;} int GetX() const {return x;}private: int x;};int main(){ Point a(10); cout << (++a).GetX(); cout << a++.GetX(); return 0;}编译和运行情况是()
发布于 2021-03-31 18:35:33
- 体验AI问答!更聪明、超智能!
- 一款基于GPT的超级AI助手,可以对话、创作、写文案!