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

📄 frn_plus.cpp

📁 不错书对C++/C程序员很有用的大家不要错过.
💻 CPP
字号:
#include <iostream.h>

class loc 
{
  int longitude, latitude;
  public:
    loc(void) {}                //  Used to construct temporaries
    loc (int lg, int lt)
      {
      longitude = lg;
      latitude = lt;
      }

    void show(void)
      {
      cout << longitude << " ";
      cout << latitude << endl;
      }

    friend loc operator+(loc op1, loc op2);   //  Friend overloader
    loc operator=(loc op2);
  };

loc operator+(loc op1, loc op2)
  {
  loc temp;
  
  temp.longitude = op1.longitude + op2.longitude;
  temp.latitude = op1.latitude + op2.latitude;
  return temp;
  }

loc loc::operator=(loc op2)
  {
  longitude = op2.longitude;
  latitude = op2.latitude;

  return *this;
  }

void main(void)
  {
  loc ob1(10,20), ob2(5,30);

  ob1 = ob1+ob2;
  ob1.show();
  }

⌨️ 快捷键说明

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