View Single Post
  #1  
Old 13-11-2008, 01:09 AM
BSIT07-01's Avatar
BSIT07-01 BSIT07-01 is offline
Addicted to Computer


 
Join Date: Sep 2007
Location: ------------
Age: 36
Posts: 1,309
Contact Number: ---------------
Program / Discipline: BSIT
Class Roll Number: 07-01
BSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant future
Default [Assignment] Solution Q no 1 ch#9 Object Oriented Programming in c++ by Robert Lafore

Just copied from book
Code:
#include <iostream>
#include <string>
using namespace std;

   
   
class publication           
   {
   private:
    string title;
    float price;
      public:
    void getdata()
    {
    cout << "\nEnter title: "; cin >> title;
    cout << "Enter price: "; cin >> price;
    }
    void putdata() const
    {
    cout << "\nTitle: " << title;
    cout << "\nPrice: " << price;
    }
      };
 
   
   
   
   class book : private publication      
      {
      private:
    int pages;
      public:
    void getdata()
    {
    publication::getdata();
    cout << "Enter number of pages: "; cin >> pages;
    }
    void putdata() const
    {
    publication::putdata();
    cout << "\nPages: " << pages;
    }
      };

   
   
   
   
   class tape : private publication      
      {
      private:
    float time;
      public:
    void getdata()
    {
    publication::getdata();
    cout << "Enter playing time: "; cin >> time;
    }
    void putdata() const
    {
    publication::putdata();
    cout << "\nPlaying time: " << time;
    }
      };
   ////////////////////////////////////////////////////////////////
   int main()
      {
      book book1;             
      tape tape1;
   
      book1.getdata();        
      tape1.getdata();
   
      book1.putdata();         
      tape1.putdata();
      cout << endl;
      return 0;
      }

Reply With Quote