一句话理解
Vector operator+(const Vector& other);
为什么要学
后面写更大的程序时,operator 会反复出现。先在小例子里跑通。
讲解
例如:
Vector operator+(const Vector& other);
掌握:
+
-
*
/
==
!=
<
>
[]
()
->
<<
>>
=
++
--
等运算符重载。
例子
#include <bits/stdc++.h>
using namespace std;
int main() {
Vector operator+(const Vector& other);
return 0;
}
动手
下面的编辑器就在浏览器里编译运行,不用装本地编译器。改一改数字、再点运行。