⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 f0807.cpp

📁 it is a usefull thing
💻 CPP
字号:
//=====================================
// f0807.cpp
// member & non-member operator
//=====================================
#include<iostream>
using namespace std;
//-------------------------------------
class Point{
  int x, y;
public:
  void set(int a, int b){ x=a, y=b; }
  Point operator+(const Point& d){
    Point s;
    s.set(x+d.x, y+d.y);
    return s;
  }//----------------------------------
  friend ostream& operator<<(ostream& o, const Point& d);
};//===================================
inline ostream& operator<<(ostream& o, const Point& d){
  return o<<"("<<d.x<<","<<d.y<<")\n";
}//====================================
int main(){
  Point s,t;
  s.set(2,5);
  t.set(3,1);
  cout<<s+t;
}//====================================

 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -