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

📄 com_over.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;
      }

    loc operator+(loc op2);
    loc operator,(loc op2);
  };

loc loc::operator,(loc op2)
 {
   loc temp;

   temp.longitude = op2.longitude;
   temp.latitude = op2.latitude;
   cout << op2.longitude << "  " << op2.latitude << endl;
   return temp;
 }

loc loc::operator+(loc op2)
 {
   loc temp;

   temp.longitude = op2.longitude + longitude;
   temp.latitude = op2.latitude + latitude;
   return temp;
 }

void main(void)
  {
   loc obj1(10,20), obj2( 5,30), obj3(1,1), temp;

   obj1.show();
   obj2.show();
   obj3.show();
   cout << endl;
   obj1 = (obj1, obj2 + obj2, obj2 + obj3);
   obj1.show();                      // Will display 6,31, obj2 + obj3's value
  }

⌨️ 快捷键说明

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