-
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
function-args-by-value: Also take into account manually defined ==/= …
…operators
- Loading branch information
Showing
4 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include <cstdio> | ||
|
||
struct Color | ||
{ | ||
unsigned int r; | ||
unsigned int g; | ||
unsigned int b; | ||
unsigned int opacity; | ||
|
||
Color &operator=(const Color &c) = default; | ||
bool operator==(const Color &c) const = default; | ||
Color(const Color &c) = default; | ||
Color() = default; | ||
}; | ||
struct Color2 | ||
{ | ||
unsigned int r; | ||
unsigned int g; | ||
unsigned int b; | ||
unsigned int opacity; | ||
|
||
Color2 &operator=(const Color2 &c) { | ||
r=c.r; | ||
g=c.g; | ||
b=c.b; | ||
opacity =c.opacity; | ||
return *this; | ||
} | ||
bool operator==(const Color2 &c) const { | ||
return c.b == b; | ||
} | ||
}; | ||
|
||
int main() | ||
{ | ||
Color c; | ||
c.r = 3; | ||
|
||
Color c2; | ||
c2 = c; | ||
|
||
Color c3(c2); | ||
|
||
|
||
Color2 otherType; | ||
Color2 otherType2; | ||
|
||
otherType2 = otherType; | ||
|
||
printf("C2.r %d\n", c2.r); | ||
printf("C3.r %d\n", c3.r); | ||
} | ||
|
Empty file.