home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 6.ddi / TASMEXMP.ZIP / COUNTADD.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.3 KB  |  42 lines

  1. class count_add {
  2.      // Private member variables:
  3.      int access_count;  // Number of times this is accessed
  4.      int count;         // The ongoing count
  5.    public:
  6.         count_add(void){ access_count=0;
  7.                         count=0;
  8.                       }
  9.         int  get_count(void){return count;}
  10.  
  11.         // Two functions that will actually be written 
  12.         // in assembler: 
  13.         void increment(void);
  14.         void add(int what_to_add=-1); 
  15.          // Note that the default value only
  16.          // affects calls to add, it does not
  17.          // affect the code for add.
  18. }
  19.  
  20. extern "C" {
  21.   // To create some unique, meaningful names for the 
  22.   // assembler routines, prepend the name of the class 
  23.   // to the assembler routine. Unlike some assemblers, 
  24.   // Turbo Assembler has no problem with long names.
  25.   void count_add_increment(int *count);  // We will pass a 
  26.                                          // pointer to the
  27.                                          // count variable. 
  28.                                          // Assembler will
  29.                                          // do the incrementing.
  30.   void count_add_add(int *count,int what_to_add);
  31. }
  32.  
  33. void count_add::increment(void)
  34. {
  35.   count_add_increment(&count);
  36. }
  37.  
  38. void count_add::add(int what_to_add)
  39. {
  40.   count_add(&count,int what_to_add);
  41. }
  42.