Skip to content

Instantly share code, notes, and snippets.



Last active Aug 29, 2015
What would you like to do?
C++ classes have themselves as implicit inner class
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
You can’t perform that action at this time.