home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / SAMPLES / COMPILER / SAMPLE06 / GENTREE.C < prev    next >
Text File  |  1993-04-03  |  3KB  |  61 lines

  1. //+----------------------------------------------------------------------------+
  2. //| GENTREE.C                                                                  |
  3. //|                                                                            |
  4. //| COPYRIGHT:                                                                 |
  5. //| ----------                                                                 |
  6. //|  Copyright (C) International Business Machines Corp., 1992,1993.           |
  7. //|                                                                            |
  8. //| DISCLAIMER OF WARRANTIES:                                                  |
  9. //| -------------------------                                                  |
  10. //|  The following [enclosed] code is sample code created by IBM Corporation.  |
  11. //|  This sample code is not part of any standard IBM product and is provided  |
  12. //|  to you solely for the purpose of assisting you in the development of      |
  13. //|  your applications.  The code is provided "AS IS", without warranty of     |
  14. //|  any kind.  IBM shall not be liable for any damages arising out of your    |
  15. //|  use of the sample code, even if they have been advised of the             |
  16. //|  possibility of such damages.                                              |
  17. //|                                                                            |
  18. //| REVISION LEVEL: 1.0                                                        |
  19. //| ---------------                                                            |
  20. //|                                                                            |
  21. //+----------------------------------------------------------------------------+
  22. // Class Name : GenTree<T>                                                     |
  23. // Purpose    : Create a Template Class to encapsulate TreeNode members.       |
  24. //              This class uses the TreeData class, and is still quite         |
  25. //              dependent on its functions. We are slowly evolving into        |
  26. //              the full use of templates.                                     |
  27. //+----------------------------------------------------------------------------+
  28.  
  29. template <class T>
  30. GenTree<T>::GenTree(GenTree<T> *pGenTree): TreeNode(pGenTree),
  31.               MyData(pGenTree->MyData)
  32. {
  33.    if (NULL != pGenTree)
  34.       myState= pGenTree->myState;
  35. }
  36.  
  37. template <class T>
  38. GenTree<T>::GenTree(const GenTree<T> &rGenTree):
  39.    TreeNode(rGenTree),MyData(rGenTree.MyData)
  40. {
  41.    myState= rGenTree.myState;
  42. }
  43.  
  44. template <class T>
  45. GenTree<T> &GenTree<T>::operator= (const GenTree<T> &rGenTree)
  46. {
  47.    if (this != &rGenTree)
  48.    {
  49.       *((TreeNode *)this)= rGenTree;
  50.       MyData= rGenTree.MyData;
  51.    }
  52.    return *this;
  53. }
  54.  
  55. //template <class T>
  56. //void GenTree<T>::display()
  57. //{
  58. //   printf("Data  = %s\n",(char *)MyData.getData());
  59. //   printf("State = %d\n",(short)getState());
  60. //}
  61.