#include <iostream.h>
#include <conio.h>
#include <string.h>
const int size = 10;
class country
{
protected :
char name[size];
int nostate;
public:
country();
void input()
{
cout<<"Enter Name of Country: ";
cin>>name;
cout<<"Total Number of States : ";
cin>>nostate;
}
void disp()
{
cout<<"Name of the Country : "<<name<<"\n";
cout<<"Total number of states : "<<nostate<<"\n";
}
};
country::country ()
{
strcpy(name," ");
nostate = 0;
cout<<" Display the Values Initialised by the Constructors Country()\n";
cout<<"Name "<<name<<" NoState "<<nostate<<"\n";
}
class state: public country
{
protected :
char name[size];
double novill;
public:
state();
void input()
{
country:: input();
cout<<"Enter Name of State : ";
cin>>name;
cout<<"Total Number of Villages : ";
cin>>novill;
}
void disp()
{
country:: disp();
cout<<"State : "<<name<<"\n";
cout<<"Total Villages : "<<novill<<"\n";
}
};
state:: state()
{
strcpy(name," ");
novill=0;
cout<<"Display the Values Initialised by the Constructors State\n";
cout<<"Name "<<name<<"NoVill "<<novill<<"\n";
}
void main( )
{
clrscr();
state sl;
sl.input();
sl.disp();
getch();
}
Dinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.
Search Content
Popular Article
Basic Courses
Advance Courses