Last active
August 29, 2015 14:07
-
-
Save emlun/6df03ac4e3819603f189 to your computer and use it in GitHub Desktop.
C++ classes have themselves as implicit inner class
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
struct Foo { | |
int x; | |
Foo() : x(0) {}; | |
explicit Foo(int x) : x(x) {}; | |
bool operator>(const Foo& other) const { | |
return x > other.x; | |
} | |
}; | |
int main() { | |
const Foo a; | |
const typename Foo::Foo b(1); | |
const typename Foo::Foo::Foo c(2); | |
const bool a_gt_b = a > b; | |
const bool a_gt_c = a > c; | |
const bool b_gt_a = b > a; | |
const bool b_gt_c = b > c; | |
const bool c_gt_a = c > a; | |
const bool c_gt_b = c > b; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment