/*
Date: 11/03/21 15:22
Description: 重載操作符的定義
可以重載的操作符(42個)
+ - * / % ^
& | ~ ......
不可以重載的操作符(4個)
:: .* . ?:
重載操作符的注意事項
*/
#include<iostream>
using namespace std;
class Person
{
//重載加法運算符
public:
void operator+(const Person& rhs)
{
cout<<"執行了重載的加法操作"<<endl;
}
};
int main()
{
int a,b;
a = 12;
b = 9;
cout<<a+b<<endl;
Person p1,p2;
p1 + p2;
return 0;
}