over_dec.cpp
Upload User: dq031136
Upload Date: 2022-08-08
Package Size: 802k
Code Size: 1k
Development Platform:

C++ Builder

  1. // This file will not compile under TCLite because it does not support
  2. // dual-overloaded decrement operators
  3. #include <iostream.h>
  4. #include <iomanip.h>
  5. #include <string.h>
  6. class String 
  7. {
  8.   public:
  9.     String String::operator--()
  10.       { buffer[length-1] = NULL;
  11.         length--;
  12.         return *this; };
  13.     String String::operator--(int x)
  14.       { buffer[length-1] = NULL;
  15.         length--;
  16.         return *this; };
  17.     String(char *string)
  18.       { strcpy(buffer, string);
  19.         length = strlen(buffer); }
  20.     void show_string(void) { cout << buffer << endl; };
  21.   private:
  22.     char buffer[256];
  23.     int length;
  24. };
  25. void main(void)
  26.  {
  27.    String title("Jamsa's C/C++ Programmer's Bible");
  28.    title--;
  29.    title.show_string();
  30.    --title;
  31.    title.show_string();
  32.  }