Posted by : Ali Khan Sunday, 7 July 2013

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







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 ofVoter.



  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 ofVoter.


Leave a Reply

Subscribe to Posts | Subscribe to Comments

- Copyright © virtual university of pakistan - Skyblue - Powered by Blogger - Designed by Johanes Djogan -