fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class scope{
  5. public:
  6. virtual void draw() = 0;
  7. };
  8. class circle:public scope{
  9. public:
  10. void draw(){cout<<"draw circle.";}
  11. };
  12. class triangle:public scope{
  13. public:
  14. void draw(){cout<<"draw triangle.";}
  15. };
  16. class geoobj{
  17. public:
  18. geoobj(scope* _obj){_obj->draw();}
  19. };
  20.  
  21. int main(){
  22. geoobj test(new circle());
  23. geoobj test2(new triangle());
  24. return 0;
  25. }
Success #stdin #stdout 0.01s 2812KB
stdin
Standard input is empty
stdout
draw circle.draw triangle.