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

  1. //+----------------------------------------------------------------------------+
  2. //| DATNTREE.CPP                                                               |
  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. //| Author      : njC Sales                                                    |
  23. //| Date        : 27 October 1992                                              |
  24. //+----------------------------------------------------------------------------+
  25.  
  26. #include "datntree.hpp"
  27.  
  28. //+----------------------------------------------------------------------------+
  29. //| Define constructors                                                        |
  30. //+----------------------------------------------------------------------------+
  31. DataInTree::DataInTree(void *pString): TreeNode(), MyData(pString)
  32. {
  33.    if (NULL != pString)
  34.       myState= TreeNode::Leaf;
  35. }
  36.  
  37. DataInTree::DataInTree(DataInTree *pDataInTree): TreeNode(pDataInTree),
  38.               MyData(pDataInTree->MyData)
  39. {
  40.    if (NULL != pDataInTree)
  41.       myState= pDataInTree->myState;
  42. }
  43.  
  44. DataInTree::DataInTree(const DataInTree &rDataInTree):
  45.    TreeNode(rDataInTree),MyData(rDataInTree.MyData)
  46. {
  47.    myState= rDataInTree.myState;
  48. }
  49.  
  50. //+----------------------------------------------------------------------------+
  51. //| Assignment                                                                 |
  52. //+----------------------------------------------------------------------------+
  53. DataInTree &DataInTree::operator= (const DataInTree &rDataInTree)
  54. {
  55.    if (this != &rDataInTree)
  56.    {
  57.       *((TreeNode *)this)= rDataInTree;
  58.       MyData= rDataInTree.MyData;
  59.    }
  60.    return *this;
  61. }
  62.  
  63. //+----------------------------------------------------------------------------+
  64. //| Display data                                                               |
  65. //+----------------------------------------------------------------------------+
  66. void DataInTree::display()
  67. {
  68.    printf("Data  = %s\n",(char *)MyData.getData());
  69.    printf("State = %d\n",(short)getState());
  70. }
  71.