Saved Bookmarks
| 1. |
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 stringDistance floatPopulation long intMember functions :DINPUT( ) : To enter Dname, Distance and populationDOUTPUT( ) : To display the data members on the scree |
|
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; } }; |
|