?? frn_plus.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 + -