home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c081_7 / 1.ddi / CLASSINC.ZIP / ASSOC.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-13  |  2.4 KB  |  100 lines

  1. // Borland C++ - (C) Copyright 1991 by Borland International
  2.  
  3. // Contents ----------------------------------------------------------------
  4. //
  5. //         Association
  6. //         Association::Association
  7. //         Association::Association                    copy constructor
  8. //
  9. // Description
  10. //
  11. //         Defines the class Association, which is an object that can
  12. //         be stored in a Dictionary.  An Association contains references
  13. //         to two Objects, a Key and a Value.
  14. //
  15. // End ---------------------------------------------------------------------
  16.  
  17. // Interface Dependencies ---------------------------------------------------
  18.  
  19. #ifndef __ASSOC_H
  20. #define __ASSOC_H
  21.  
  22. #ifndef __IOSTREAM_H
  23. #include <iostream.h>
  24. #define __IOSTREAM_H
  25. #endif
  26.  
  27. #ifndef __CLSTYPES_H
  28. #include <clstypes.h>
  29. #define __CLSTYPES_H
  30. #endif
  31.  
  32. #ifndef __OBJECT_H
  33. #include <object.h>
  34. #define __OBJECT_H
  35. #endif
  36.  
  37. // End Interface Dependencies ------------------------------------------------
  38.  
  39. // Class //
  40.  
  41. class Association : public Object
  42. {
  43. public:
  44.             Association( Object& k, Object& v ) : aKey( k ), aValue( v ) {}
  45.             Association( const Association& a ) :
  46.                                     aKey( a.key() ), aValue( a.value() ) {}
  47.     virtual ~Association();
  48.  
  49.             Object&         key() const { return aKey; }
  50.             Object&         value() const { return aValue; }
  51.  
  52.     virtual classType       isA() const;
  53.     virtual char           *nameOf() const;
  54.     virtual hashValueType   hashValue() const;
  55.     virtual int             isEqual( const Object& ) const;
  56.     virtual int             isAssociation() const;
  57.     virtual void            printOn( ostream& ) const;
  58.  
  59. private:
  60.             Object&            aKey;
  61.             Object&            aValue;
  62. };
  63.  
  64. // Description -------------------------------------------------------------
  65. //
  66. //         Defines an association class.  An association keeps two objects
  67. //         together and treats them as a single object.
  68. //
  69. // Constructors
  70. //
  71. //         Association( Object& k, Object& v )
  72. //
  73. //         Constructor from two objects.
  74. //
  75. //         Association( Association& a )
  76. //
  77. //         Copy constructor.
  78. //
  79. // Public Members
  80. //
  81. //         key
  82. //
  83. //         Returns a reference to the key
  84. //
  85. //         value
  86. //
  87. //         Returns a reference to the value of the association.
  88. //
  89. // Private Members
  90. //
  91. //      aKey
  92. //
  93. //      aValue
  94. //
  95. // End ---------------------------------------------------------------------
  96.  
  97.  
  98. #endif // ifndef __ASSOC_H //
  99.  
  100.