fork download
  1. #include <iostream>
  2.  
  3. template<typename T, typename U>
  4. class e
  5. {
  6. void Print() //call this function!
  7. {
  8. std::cout << "You haxxor..." << std::endl;
  9. }
  10. public:
  11. T g()
  12. {
  13. return&U::Print;
  14. }
  15. };
  16.  
  17. struct Foo {
  18. static const int Print = 0;
  19. };
  20.  
  21. int main() {
  22. e<void (e<int*, Foo>::*)(), e<int*, Foo> > e1;
  23. void (e<int*, Foo>::*ptr)() = e1.g();
  24. e<int*, Foo> e2;
  25. (e2.*ptr)();
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In member function ‘T e<T, U>::g() [with T = void (e<int*, Foo>::*)(), U = e<int*, Foo>]’:
prog.cpp:23:   instantiated from here
prog.cpp:6: error: ‘void e<T, U>::Print() [with T = int*, U = Foo]’ is private
prog.cpp:13: error: within this context
stdout
Standard output is empty