- Back to Home »
- CS304 Assignment no 5 Spring 2013 Full Solution
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:
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:
- Make Voter base/parent class and inherit classes Disable and Overseas from it.
- In voter class:
- Make Cast_vote ( ) function a pure virtual function.
- Login_data () should be a non-virtual function.
- In Disable class:
- Make Cast_vote() a virtual function.
- 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.
- In Overseas class:
- Make Cast_vote() a virtual function.
- 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.