Over_inc.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 increment operators
  3. #include <iostream.h>
  4. #include <iomanip.h>
  5. #include <string.h>
  6. class String 
  7. {
  8.   public: 
  9.     String String::operator++()
  10.       { strcat(buffer, "X");
  11.         return *this; };
  12.     String String::operator++(int x)
  13.       { strcat(buffer, "X");
  14.         return *this; };
  15.     String(char *string)
  16.       { strcpy(buffer, string);
  17.         length = strlen(buffer); }
  18.     void show_string(void) { cout << buffer << endl; };
  19.   private:
  20.     char buffer[256];
  21.     int length;
  22. };
  23. void main(void)
  24.  {
  25.    String title("Jamsa's C/C++ Programmer's Bible");
  26.    title++;
  27.    title.show_string();
  28.    ++title;
  29.    title.show_string();
  30.  }