C++
- voluntas
- @ignis_fatuus
- ブン
- @Linda_pp
- 清楚なC++メイドBOT
- @tzik_tack
- 長谷川一輝
- wraith13
- @jj1bdx
- @cpp_akira
- 安藤敏彦
- @srz_zumix
- Siv3D
- takezoh
- まろ
- @okdshin
- @hnokx
- @ishidakei
- @take_cheeze
- TAKEI Yuya
- @mumumu
- I (@wx257osn2)
- Tommy6
- @tyottyoworks
- ___shanon
- わたやん
- @KorekaraSEDB
- @kariya_mitsuru
- @ciniml
- @beam2d
- @grafi_tt
- @nekketsuuu
- LouiS0616
- @volanja
- 大鎌広
- むてら
- ガチKGB
- 三重野賢人
x
29
1
2
3
using namespace std;4
5
class Coordinates{6
public:7
int x, y, z;8
Coordinates(int x,int y,int z) {9
this->x = x;10
this->y = y;11
this->z = z;12
}13
Coordinates(){}14
friend bool operator==(const Coordinates&, const Coordinates&);15
};16
17
bool operator==(const Coordinates& other, const Coordinates& other_2) {18
return (other.x==other_2.x && other.y == other_2.y && other.z == other_2.z);19
}20
int main()21
{22
Coordinates pos_1(1,3,5);23
Coordinates pos_2(1, 3, 7);24
if (pos_1 == pos_2) {25
cout << "\n\nCoordinates are equal";26
}27
else cout << "\n\nCoordinates are not equal";28
}29
$ g++ prog.cc -Wall -Wextra -I/opt/wandbox/boost-1.73.0/gcc-10.1.0/include -std=c++11 -pedantic
Start
Coordinates are not equal
0
Finish