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

C++ Builder

  1. #include <iostream.h>                                                
  2. #include <string.h>
  3. class StringClass 
  4. {
  5.  public:
  6.    void str_reverse(char *string) 
  7.    { 
  8.      if (*string)
  9.        {
  10.          str_reverse(string+1);
  11.          cout.put(*string);
  12.        }
  13.    };
  14.    int str_length(char *string) 
  15.    {
  16.        if (*string)    
  17.          return (1 + str_length(++string));
  18.        else
  19.          return(0);
  20.      };
  21.    StringClass(char *string) { strcpy(StringClass::string, string); };
  22.    char string[256];
  23. };
  24. void main(void)
  25.  {
  26.    StringClass title("Jamsa's C/C++ Programmer's Bible");
  27.    title.str_reverse(title.string);
  28.    cout << endl << "The title is " << 
  29.      title.str_length(title.string) << " bytes long.";
  30.  }