Guest User

Untitled

a guest
Jun 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. template<class T>
  2. class AbstractTree
  3. {
  4.   T data;
  5.   AbstractTree *left, *right;
  6. public:
  7.   AbstractTree( T &inc ) : left(NULL), right(NULL), data(inc){}
  8.  
  9.   virtual void setData( const T &d)
  10.   {
  11.     data = d;
  12.   }
  13.  
  14.   virtual T getData() const
  15.   {
  16.     return data;
  17.   }
  18.    
  19.   virtual AbstractTree getLeft() const
  20.   {
  21.     return left;
  22.   }
  23.  
  24.   virtual AbstractTree getRight() const
  25.   {
  26.     return right;
  27.   }
  28.  
  29.   virtual int addLeft( const AbstractTree *a )
  30.   {
  31.     if(left != NULL){
  32.       return 1;
  33.     }
  34.     left = a;
  35.     return 0;
  36.   }
  37.  
  38.   virtual int addRight( const AbstractTree *a )
  39.   {
  40.     if(right != NULL){
  41.       return 1;
  42.     }
  43.     right = a;
  44.     return 0;
  45.   }
  46. };
Add Comment
Please, Sign In to add comment