fork download
  1. #include <iostream>
  2.  
  3. class Test {
  4. public:
  5. Test(){}
  6.  
  7. typedef bool(*Fun)();
  8.  
  9. Fun F() {
  10. return [=]()->bool {return this->Show(); };//invalid...Orz
  11. }
  12. bool Show() {
  13. std::cout << "seikou!" << std::endl;
  14. }
  15. };
  16.  
  17. int main() {
  18. Test T;
  19.  
  20. auto f = T.F();
  21.  
  22. f();
  23.  
  24. return 0;
  25. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In member function ‘bool (* Test::F())()’:
prog.cpp:10:44: error: cannot convert ‘Test::F()::<lambda()>’ to ‘Test::Fun {aka bool (*)()}’ in return
   return [=]()->bool {return this->Show(); };//invalid...Orz
                                            ^
stdout
Standard output is empty