You are on page 1of 4

Multi-Level inheritance

#include<iostream>

using namespace std;

class pol_st{

long double
CNIC[10]={2323232322,546435424354,436432453265,423254332437,53643254326,45645435432,4354
3241342,65356423432,6533254326,54436325437};

int a;

long double b=0;

public:

pol_st(){

cout<<"Welcome to Polling station Sialkot!"<<endl;

~pol_st(){

cout<<"Thank You"<<endl;

void party(){

cout<<"\n\nList of Parties"<<endl;

cout<<"\n1:PTI\t2:PMLN\t3:PPP\t4:MQM"<<endl;

int verify(){

cout<<"Enter your CNIC number: ";

cin>>a;

for(int i=0; i<10; i++)

if(CNIC[i]==a){

cout<<"Already casted a vote"<<endl;


}

else

cout<<"1st time casting a vote"<<endl;

party();

};

class voterside:public pol_st{

int x, a1=0,a2=0,a3=0,a4=0;

public:

void func(){

verify();

cout<<"\nChoose one party tp caste a vote"<<endl;

cin>>x;

switch(x)

case 1:

a1++;

break;

case 2:

a2++;

break;

case 3:

a3++;

break;

case 4:

a4++;
break;

default:

cout<<"Invalid Entry";

};

class systemside:public voterside{

public:

void display(){

cout<<"Result of all parties"<<endl;

cout<<"Total PTI votes: "<<a1<<endl;

cout<<"Total PMLN votes: "<<a2<<endl;

cout<<"Total MQM votes: "<<a4<<endl;

cout<<"Total PPP votes: "<<a3<<endl; }

int output(){

cout<<"Name of Winning Party"<<endl;

if(a1>a2 && a1>a3 && a1>a4)

cout<<"PTI WINS"<<endl;

else if(a2>a1 && a2>a3 && a2>a4)

cout<<"PMLN WINS"<<endl;

else if(a3>a1 && a3>a2 && a3>a4)

cout<<"PPP WINS"<<endl;

else

cout<<"MQM WINS "<<endl;

};

int main(){

pol_st p;

for(int j=0;j<10;j++){
p.func();

system side s;

return 0;

You might also like