+1 vote
in Class 12 by kratos

Consider the following class State :

class State

{

protected :

int tp;

public :

State( ) { tp=0;}

void inctp( ) { tp++;};

int gettp(); { return tp; }

};

Write a code in C++ to publically derive another class ‘District’ with the following additional members derived in the public visibility mode.

Data Members :

Dname string

Distance float

Population long int

Member functions :

DINPUT( ) : To enter Dname, Distance and population

DOUTPUT( ) : To display the data members on the scree

1 Answer

+2 votes
by kratos
 
Best answer

class District : public State

{

public :

char Dname[20];

float Distance;

long int Population;

void DINPUT( )

{

gets(Dname);

cin>>distance;

cin>>Population;

}

void DOUTPUT( )

{

cout<<Dname<<endl;

cout<<Distance<<endl;

cout<<population<<endl;

}

};

...