fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class CodeGenerator{
  6. public:
  7. void AddLineToBody(string str);
  8. void print() {cout << bodyASM;}
  9. private:
  10. string bodyASM;
  11. };
  12.  
  13. void CodeGenerator::AddLineToBody(string str)
  14. {
  15. bodyASM += str;
  16. bodyASM += "\n";
  17. }
  18.  
  19. int main() {
  20.  
  21. void (CodeGenerator::*AddLine)(string);
  22. AddLine = &CodeGenerator::AddLineToBody;
  23. class CodeGenerator *stroka = new CodeGenerator;
  24. (stroka->*AddLine)("str");
  25. stroka->print();
  26. return 0;
  27. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
str