Showthis.cpp
上传用户:dq031136
上传日期:2022-08-08
资源大小:802k
文件大小:1k
源码类别:

VC书籍

开发平台:

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.  }