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