BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan Right Header

HOME BZU Mail Box Online Games Radio and TV Cricket All Albums
Go Back   BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan > Institute of Computing > Bachelor of Science in Information Technology > BsIT 3rd Semester > Object Oriented Programming

Object Oriented Programming By Mam Sidra Malik


Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 13-11-2008, 01:02 AM
BSIT07-01's Avatar
Addicted to Computer


 
Join Date: Sep 2007
Location: ------------
Age: 34
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] Q no 5 ch#9 Object Oriented Programming in c++ by Robert Lafore



Code:
#include <iostream>
using namespace std;
const int LEN = 80;                




class employee                     
   {
   private:
      char name[LEN];              
      unsigned long number;       
   public:
      void getdata()
      {
      cout << "\n   Enter last name: "; cin >> name;
      cout << "   Enter number: ";      cin >> number;
      }
      void putdata() const
      {
      cout << "\n   Name: " << name;
      cout << "\n   Number: " << number;
      }
   };




class employee2 : public employee
{
private:

double compensation;

public:

      void getdata()
      {
      
          employee::getdata();
          cout << "\n   Enter Compensation: "; cin >> compensation;
      
      }
      void putdata() const
      {
          employee::putdata();
          cout << "\n   Compensation : " << compensation;
      
      }


};






class manager : public employee2    
   {
   private:
      char title[LEN];             
      double dues;                 
   public:
      void getdata()
      {
      employee2::getdata();
      cout << "   Enter title: ";          cin >> title;
      cout << "   Enter golf club dues: "; cin >> dues;
      }
      void putdata() const
      {
      employee2::putdata();
      cout << "\n   Title: " << title;
      cout << "\n   Golf club dues: " << dues;
      }
   };



class scientist : public employee2  
   {
   private:
      int pubs;                   
   public:
      void getdata()
      {
      employee2::getdata();
      cout << "   Enter number of pubs: "; cin >> pubs;
      }
      void putdata() const
      {
      employee2::putdata();
      cout << "\n   Number of publications: " << pubs;
      }
   };





class laborer : public employee2   
   {
   };




int main()
   {
   manager m1, m2;
   scientist s1;
   laborer l1;

   cout << endl;           
   cout << "\nEnter data for manager 1";
   m1.getdata();

   cout << "\nEnter data for manager 2";
   m2.getdata();

   cout << "\nEnter data for scientist 1";
   s1.getdata();

   cout << "\nEnter data for laborer 1";
   l1.getdata();
                  
   cout << "\nData on manager 1";
   m1.putdata();

   cout << "\nData on manager 2";
   m2.putdata();

   cout << "\nData on scientist 1";
   s1.putdata();

   cout << "\nData on laborer 1";
   l1.putdata();
   cout << endl;
   return 0;
   }

Reply With Quote
Reply

Tags
assignment, ch#9, lafore, object, oriented, programming, robert


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Book] Object-Oriented Programming in C++, 3rd Edition BSIT07-01 Object Oriented Programming 1 16-03-2011 06:52 PM
[Assignment] Solution Q no 1 ch#9 Object Oriented Programming in c++ by Robert Lafore BSIT07-01 Object Oriented Programming 1 15-03-2011 08:09 PM
Object Oriented Programming Final Term Paper BsIT07 December 2008 By madam Sidra .BZU. Object Oriented Programming 0 22-12-2008 04:07 PM
About Object Oriented programming full notes usman_akhtar Object Oriented Programming 1 21-10-2008 10:08 PM
Mid Term Paper Object Oriented Programming BIT07 3rd Semester .BZU. Object Oriented Programming 0 14-10-2008 12:06 PM

Best view in Firefox
Almuslimeen.info | BZU Multan | Dedicated server hosting
Note: All trademarks and copyrights held by respective owners. We will take action against any copyright violation if it is proved to us.

All times are GMT +5. The time now is 09:54 AM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.