Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

Assignment No. 05
SEMESTER Spring 2013
CS304- Object Oriented Programming

Total Marks: 20

Due Date: 05/07/2013


Please read the following instructions carefully before solving & submitting assignment:

It should be clear that your assignment will not get any credit (zero marks) if:

  • The assignment is submitted after due date.
  • The submitted assignment is other than .cpp file.
  • The submitted assignment does NOT open or file is corrupted.
  • The assignment is copied (from other student or ditto copy from handouts or internet).

Uploading instructions


  • For clarity and simplicity, you are required to Upload/Submit only .CPP file


The objective of this assignment is:


  • To give you the idea of practical implementation of concepts inheritance and polymorphism.


For any query about the assignment, contact at



Marks: 20 

Consider the following Class Diagram; detailed description of the diagram is given in the table.


Class Name

Attribute Name

Attribute Data Type

Behavior (Functions)



Character String

-Default Constructor()

-Login _data()














In given class diagram, voter is a base class; while Disable and Overseas is its derived classes sharing its all attributes and functions.


You are required to implement the above class diagram in C++. For this you have to use the concept of inheritance and polymorphism. In order to cast vote, your program should be able to produce different interfaces for each category of voter e.g. interface for disable voter should be different from the interface of overseas voter.


Solution Guidelines:


  1. Make Voter base/parent class and inherit classes Disable and Overseas from it.
  2. In voter class:
    1. Make Cast_vote ( ) function a pure virtual function.
    2. Login_data() should be a  non-virtual function.


  1. In Disable class:
    1. Make Cast_vote() a virtual function.
    2. Login_data( ) function of disable class should generate an interface that would help disable voters to cast their vote easily. In the body of this function, you also have to call Login_data() function of Voter.


  1. In Overseas class:
    1. Make Cast_vote() a virtual function.
    2. Cast_vote()  function of overseas class should generate an interface that would help overseas voters to cast their vote easily. In the body of this function, you also have to call Login_data() function of Voter

Sample Output:



Lectures Covered:  This assignment covers Lecture #   22-31

Deadline:             Your assignment must be uploaded/submitted at or before. 5th July , 2013


Views: 7334


Replies to This Discussion

Please discuss this assignment before due date

vu walo ny lagta hmy insan ni janwarsamjh rakha hy, per day lecture b 6,,, 6 kar diye r asg b dhara dhar bejhy ja rahy,


bilkul sahi kaha, pagal kar dia he


hahahahhahhaahhahahaha... ma to dheeeeeeeeeeeeet ho gea hn ab phly tension hti thi ab aadi ho gaye hain

i agree

Please Discuss here about this assignment.Thanks

Our main purpose here discussion not just Solution

We are here with you hands in hands to facilitate your learning and do not appreciate the idea of copying or replicating solutions.

Dear All my seniors, Expert, superior, Genius and Programmer, We deeply request you to help us in order to make the last CS304_Assignment#5 as it is our last assignment and most of us want a unique solution from each other. Please help us in this way so every one could prepare his own assignment to get rid of this subject. We know everyone is so busy but we will be thankful if you could get some spare time for you. In return, we can only give you prayers.

virtual function is a function or method whose behavior can be overriden within an inheriting class by a function with the same signature.

A virtual function is a member function that is declared within a base class and redefined by a derived class. To create virtual function, precede the function’s declaration in the base class with the keyword virtual. When a class containing virtual function is inherited, the derived class redefines the virtual function to suit its own needs.

Base class pointer can point to derived class object. In this case, using base class pointer if we call some function which is in both classes, then base class function is invoked. But if we want to invoke derived class function using base class pointer, it can be achieved by defining the function as virtual in base class, this is how virtual functions support runtime polymorphism.

Consider following program code:

Class A 

        int a; 
                 a = 1; 
        virtual void show() 
                    cout a;

Class B: public A 

         int b; 
                 b = 2; 
         virtual void show() 
                  cout b;

int main() 

           A *pA; 
           B oB; 
           pA = &oB; 
           return 0; 

Output is 2 since pA points to object of B and show() is virtual in base class A

In  this assignment  mostly virtual function is used.

class Voter



virtual cast_vote(){cout"\nDo you want to cast vote: ";  cin>>ch;




class Disable: public Voter



class Overseas: Voter



virtual cast_vote();




Looking For Something? Search Below

VIP Member Badge & Others

How to Get This Badge at Your Profile DP


Management: Admins ::: Moderators

Other Awards Badges List Moderators Group

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service