         
TSET.EXE,   .            
  TSET.IDE          Project      <Ctrl+F9>  
      EasyWin-. 

     14.7.  TSET.CPP (  TSet) 

    1:	#include <iostream.h> 
    2:	#include <string.h>                                                     
    3:	#include "set.h"
    4:
    5:	class TElem {                                            
    6.	  private:            
    7:	     char *sp;    //   - 
    8:	  public: 
    9:               TElem(const char *s) { sp = strdup(s);   }
  10:	    virtual -TElem() { delete sp;   }                                   
  11:	    virtual const char GetString(void) {  return sp;   } ;                                                                 
  12:         }
  13: 
  14:	class TMySet:   public TSet {           
  15:	protected:                                                            
  16:	   virtual int CompareElems(PTElem p1,  PTElem p2);       
  17:	public:                                                                
  18:	   TMySet(int n): TSet(n) { }                 
  19: 	};
  20:
  21:	void Test(const char s,  PTSet setp); 
  22:	
  23: 	main()
  24:	{        
  25:	   TMySet thirties(12);    //   12  TElem              
  26:	
  27:	   thirties. AddElem(new TElemC'Sep"));                           
  28:	   thirties. AddElem(new TElem("Apr"));                            
  29:	   thirties. AddElem(new TElem("Jun"));                                   
  30:	   thirties. AddElem(new TElem("Nov")} ;  
  31:	  Test( "Jan", &thirties);              
  32:	  Test("Feb", &thirties);            
  33:	  Test("Mar", &thirties);                                  
  34:	  Test ("Apr", &thirties);                            
  35: 	  Test("May", &thirties);
  36:	  Test("Jun", &thirties);      
  37:	  Test("Jul",  &thirties); 
  38:	  Test("Aug", &thirties); 
  39:	  Test("Sep", &thirties); 
  40:	  Test("0ct",   &thirties);                               
  41:	  Test("Nov",  &thirties);                             
  42:	  Test("Dec",  &thirties);       
  43:	   return 0; 
  44:	} 
  45: 
  46:	// ,     s  setp 
  47:	void Test(const char *s,   PTSet setp)	
  48:	{ 
  49:	  TElem testElem(s); 
  50: 
  51:	if ( setp->HasElem( #testElem ) ) 
  52:	  cout  s  " is in the set\n"; 
  53:	else 
  54:	  cout  s  " is not in the set\n"; 
  55:           }
  56:		
  57:	//  ,     ,   -   
  58:	int TMySet: :ConpareElems( PTElem p1,  PTElem p2) 
  59:	{ 
  60:	   return (stricmp(p1->GetString(),   p2->GetString())); 
  61:	} 

         TSet    TElem.  
 TElem   .   5-12   
,TElem,    .  -  
 . 
    

    358  III.   ANSI ++
