fork(1) download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. class TextBuilder
  7. {
  8. public:
  9. virtual void Draw(string Text) = 0;
  10. };
  11.  
  12. class :public TextBuilder
  13. {
  14. public:
  15. void Draw(string Text)
  16. {
  17. cout << "Text1: " << Text << endl;
  18. }
  19. } Text1;
  20.  
  21. class :public TextBuilder
  22. {
  23. public:
  24. void Draw(string Text)
  25. {
  26. cout << "Text2: " << Text << endl;
  27. }
  28. } Text2;
  29.  
  30. void ShowString (TextBuilder &Method, string Text)
  31. {
  32. Method.Draw(Text);
  33. }
  34.  
  35. int main()
  36. {
  37. ShowString(Text1, "Adam");
  38. ShowString(Text2, "Adam");
  39. return 0;
  40. }
Success #stdin #stdout 0s 3480KB
stdin
Standard input is empty
stdout
Text1: Adam
Text2: Adam