Created
September 10, 2019 13:47
-
-
Save willianrschuck/ccdee10375e63880f6a2efd050b30c47 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
struct MinhaStruct { | |
int chave; | |
}; | |
/* | |
Os operadores de comparação não são gerados quando a struct é definida. | |
Ainda é possível as definir por si mesmo. | |
*/ | |
bool operator==(const MinhaStruct &L, const MinhaStruct &R) | |
{ | |
return L.chave == R.chave; | |
} | |
int main() { | |
MinhaStruct s1; | |
MinhaStruct s2; | |
s1.chave = 1; | |
s2.chave = 1; | |
cout << boolalpha << (s1 == s2) << endl; | |
s1.chave = 8; | |
cout << boolalpha << (s1 == s2) << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment