您的位置:首页 > 其它

重载操作符

2016-03-21 12:28 169 查看
#include <iostream>

using namespace std;

class Person
{
//  重载操作符: 加法      重载操作符就是一个函数,
public:
void operator+(const Person& rhs)
{
cout << "执行了重载的加法操作:" << endl;
}

};

int main()
{
int a, b;
a = 9;
b = 10;
cout << a + b << endl;
Person p1, p2;
p1 + p2;

cout << "xiaocui" << endl;
system("pause");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: