fun_over.cpp
来自「《C C++程序员实用大全》配套光盘源代码 欢迎下载」· C++ 代码 · 共 50 行
CPP
50 行
#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()(int i, int j);
};
loc loc::operator()(int i, int j)
{
longitude = i;
latitude = j;
return *this;
}
loc loc::operator+(loc op2)
{
loc temp;
temp.longitude = op2.longitude + longitude;
temp.latitude = op2.latitude + latitude;
return temp;
}
void main(void)
{
loc ob1(10,20), ob2( 1,1);
ob1.show();
ob1(7,8);
ob1.show();
ob1 = ob2 + ob1(10,10);
ob1.show();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?