fork download
  1. #include <iostream>
  2.  
  3. struct A {
  4. void bar();
  5. private:
  6. struct B {
  7. int i = 42;
  8. };
  9. };
  10.  
  11. /* compile error
  12. void foo(const A::B& value) {
  13. std::cout << value.i;
  14. }
  15. */
  16.  
  17. /** everything is ok */
  18. template<typename T>
  19. void foo(const T& value) {
  20. std::cout << value.i;
  21. }
  22.  
  23.  
  24. void A::bar() {
  25. A::B b;
  26. foo(b);
  27. }
  28.  
  29.  
  30. int main() {
  31. A a;
  32. a.bar();
  33. return 0;
  34. }
Success #stdin #stdout 0s 4816KB
stdin
Standard input is empty
stdout
42