ItemType definition


//  SPECIFICATION FILE		( itemtype.h )

const  int  MAX_ITEM = 5 ;
enum  RelationType { LESS, EQUAL, GREATER } ;

class  ItemType		// declares class data type
{						
public : 			//  3 public member functions
	RelationType    ComparedTo ( ItemType )  const ;
 	void	      Print ( )  const ;
	void	     	Initialize ( int  number )  ;              

private :		     //  1 private data member
	int	value  ;        // could be any different type 
} ;	

//  IMPLEMENTATION FILE		( itemtype.cpp )
//  Implementation depends on the  data type of value.

#include  “itemtype.h”
#include  


RelationType  ComparedTo ( ItemType  otherItem )  const 
{						
	if  ( value  <  otherItem.value )
		  return  LESS ;
	else  if ( value  > otherItem.value )
		  return  GREATER ;
	else  return  EQUAL ;
}
 void   Print ( ) const 
{
   using namespace std;
	cout  <<  value  <<  endl ;
}
void    Initialize ( int  number )
{
	value  =  number  ;              
} 	
 

 

 

 

© Lynne Grewe