fork download
  1. template<typename T>
  2. class MySwither{
  3. public:
  4. virtual void SetData(T data) = 0;
  5. virtual T GetData() = 0;
  6. virtual ~MySwither() {}
  7. };
  8.  
  9. class AthleteForm : public MySwither<int> {
  10. private:
  11. int a;
  12. public:
  13. AthleteForm() : a(0){}
  14. void SetData(int data){
  15. a = data;
  16. }
  17. int GetData(){
  18. return a;
  19. }
  20. };
  21.  
  22. template<typename T>
  23. class AbsObj{
  24. public:
  25. AbsObj(){}
  26. MySwither<T> *obj;
  27. };
  28.  
  29.  
  30. class IntObj : public AbsObj<int>{
  31. public:
  32. IntObj(){
  33. obj = new AthleteForm;
  34. }
  35. ~IntObj(){
  36. if(obj != nullptr){
  37. delete obj;
  38. }
  39. }
  40. };
  41.  
  42. int main(int argc, char *argv[])
  43. {
  44. IntObj obj;
  45. return 0;
  46. }
Success #stdin #stdout 0s 4288KB
stdin
Standard input is empty
stdout
Standard output is empty