#include<iostream>
#include<cstring>
using namespace std;
class city
{
protected:
char *name;
int len;
public:
void getname(void)
{
char *s;
s= new char[30];
cout<<"Enter city name: ";
cin>>s;
len= strlen(s);
name= new char[len+1];
strcpy(name,s);
}
void printname()
{
cout<<name<<"\n";
}
};
int main()
{
city *cptr[10];
int n=1;
int option;
do
{
cptr[n]= new city;
cptr[n]->getname();
n++;
cout<<"Do you want to enterone more name?\n";
cout<<"(Enter 1 for yes 0 for no):";
cin>>option;
}
while(option);
cout<<"\n";
for(int i=1; i<=n; i++)
{
cptr[i]->printname();
}
delete []cptr;
system("pause");
return 0;
}
i am getting an error after the program is over my compiler shuts down........can anyone tell whats the matter???