[C++] Operator overloading

Insert picture description here
Insert picture description here
Insert picture description here

c++中的运算符重载
例: <<
2<<3   代表左移
cout<<2;    代表将2输出到输出流
<<在不同的条件下,有不同的意思这就是运算符的重载。

例:
你在你爸妈面前是一个身份   是儿子
你在你女朋友面前又是一个身份  是男朋友

Insert picture description here
example:
Insert picture description here
Insert picture description here
Insert picture description here

通过上图你会发现,经过你自己写的" + "号重载。
" + "可以进行两个对象的相加运算。

Guess you like

Origin blog.csdn.net/qq_46527915/article/details/114026449