home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pctchnqs / 1991 / number1 / types.h < prev    next >
Text File  |  1991-03-26  |  2KB  |  61 lines

  1. // This code declares the classes for three simple data types.
  2. // The contents of a general purpose C header file should be
  3. // enclosed in a macro #ifdef clause as shown here.
  4. // This allows multiple inclusions without conflicts.
  5.  
  6.  #ifndef __TYPES_H
  7.  #define __TYPES_H
  8.  
  9.  enum datatype{EMPTY, INT, LONG, STRING, DERIVED};
  10.  class value{
  11.   protected:
  12.       char* namptr;
  13.   public:
  14.       value(); value(char* namestr); //constructor
  15.       virtual ~value();      //destructor
  16.       //return characteristics
  17.       const char* name(){return namptr;};
  18.       virtual int valid();
  19.       virtual datatype type(); virtual const char* typename();
  20.       //return value in different forms
  21.       virtual int asint();
  22.       virtual long aslong();
  23.       virtual const char* asstring();};
  24.  
  25.  
  26.  class ival:public value{
  27.   protected:
  28.       int data;
  29.   public:
  30.       ival(char* namestr, int val);
  31.       datatype type(); const char* typename();
  32.       int asint();
  33.       long aslong();
  34.       const char* asstring();};
  35.  
  36.  
  37.  class lval:public value{
  38.   protected:
  39.       long data;
  40.   public:
  41.       lval(char* namestr, long val);
  42.       datatype type(); const char* typename();
  43.       int asint();
  44.       long aslong();
  45.       const char* asstring();};
  46.  
  47.  
  48.  class sval:public value{
  49.   protected:
  50.       char* data;
  51.   public:
  52.       sval(char* namestr, char* val);
  53.       ~sval(); //supplemental destructor
  54.       datatype type(); const char* typename();
  55.       int asint();
  56.       long aslong();
  57.       const char* asstring();};
  58.  
  59.  
  60.  #endif
  61.