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

VC书籍

开发平台:

C++ Builder

  1. #include <iostream.h>
  2. #include <string.h>
  3. class Book 
  4. {
  5.   public:
  6.     Book(char *title) { strcpy(Book::title, title); }; 
  7.     void show_title(void) { cout << title << endl; };
  8.   private:
  9.     char title[64];
  10. };
  11. class LibraryCard : public Book 
  12. {
  13.   public:
  14.     LibraryCard(char *title, char *author, char *publisher) : Book(title) 
  15.       { 
  16.         strcpy(LibraryCard::author, author); 
  17.         strcpy(LibraryCard::publisher, publisher); 
  18.       };
  19.     void show_library(void) { 
  20.         show_title();
  21.         cout << author << ' ' << publisher; 
  22. };
  23.   private:
  24.     char author[64];
  25.     char publisher[64];
  26. };
  27. void main(void)
  28.  {
  29.    LibraryCard card("Jamsa's C/C++ Programmer's Bible", "Jamsa and Klander", 
  30.    "Jamsa Press");
  31.    card.show_library();
  32.  }