fork(14) download
  1. #include <iostream>
  2. template <typename T>
  3. class Key { friend T; Key() {} Key(Key const&) {} };
  4.  
  5. class Foo;
  6.  
  7. class Bar { public: void special(int a, Key<Foo>) {} };
  8.  
  9. class Foo { public: void special() { Bar().special(1, {}); } };
  10.  
  11. int main() {
  12. Foo().special();
  13. Bar().special(1, {});
  14. return 0;
  15. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:3:27: error: 'Key<T>::Key() [with T = Foo]' is private
     class Key { friend T; Key() {} Key(Key const&) {} };
                           ^
prog.cpp:13:21: error: within this context
  Bar().special(1, {});
                     ^
stdout
Standard output is empty