Showthis.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 SomeClass 
  4. {
  5.  public:
  6.    void show_with_this(void) 
  7.    {
  8.      cout << "Book: " << this->title << endl;
  9.      cout << "Author: " << this->author << endl; 
  10.    };
  11.    void show_without_this(void) 
  12.    {
  13.      cout << "Book: " << title << endl;
  14.      cout << "Author: " << author << endl; 
  15.    };
  16.    
  17.    SomeClass(char *title, char *author) 
  18.    {
  19.      strcpy(SomeClass::title, title);
  20.      strcpy(SomeClass::author, author);
  21.    };
  22.  private:
  23.    char title[256];
  24.    char author[256];
  25. };
  26. void main(void)
  27.  {
  28.    SomeClass book("Jamsa's C/C++ Programmer's Bible", "Jamsa and Klander");
  29.    book.show_with_this();
  30.    book.show_without_this();
  31.  }