fork download
  1. class User;
  2.  
  3. template <typename T, int T::*member>
  4. class Base {
  5.  
  6. };
  7.  
  8. class Used {
  9. // Befriend everything there is.
  10. friend class User;
  11. template <typename T, int T::*member> friend class Base;
  12. // The variable that should be accessible.
  13. int i;
  14. };
  15.  
  16. // error: ‘int Used::i’ is private
  17. class User : public Base<Used, &Used::i> {
  18.  
  19. };
  20.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:13: error: 'int Used::i' is private
prog.cpp:17: error: within this context
stdout
Standard output is empty