fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3. struct A {
  4.  
  5. //protected:
  6.  
  7. struct C { static void f() { cout << "A::C::f" <<endl; } };
  8.  
  9. };
  10.  
  11. struct B: A {
  12. C c1; // the only C known here is A::C
  13. struct C { static void f() { cout << "B::C::f" <<endl; }};
  14. C c2; // but here the closes C known is B::C
  15. A::C c3; // and here I can be explicit about the C I want
  16. using D=A::C; // and here another way to be explicit:
  17. D c4;
  18. };
  19.  
  20. int main() {
  21. B::C x;
  22. B::A::C y;
  23. A a = B();
  24. decltype(a)::C::f();
  25.  
  26. B b;
  27. decltype(b.c1)::C::f();
  28. decltype(b.c2)::C::f();
  29. decltype(b.c3)::C::f();
  30. decltype(b.c4)::C::f();
  31. return 0;
  32. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
A::C::f
A::C::f
B::C::f
A::C::f
A::C::f