I hope somebody can help me.
I have a file with a list of lots of cities that can be repeated. For example:
Lima, Peru
Rome, Italy
Madrid, Spain
Lima, Peru
I have created a class City with a constructor City( string cityName )
In the main, I want to create a pointer with each city, like:
City* lima = new City( City("Lima, Peru");
City* rome = new City( City("Rome, Italy");
is there a way to do this with a loop reading lines from the text, like:
City* cities = new City[];
int i = 0;
while( Not end of the file )
{
if( read line from the file hasn't been read before )
cities[i] = City(read line from the file);
}
Is there a way, or I have to do it manually for each one. Any suggestions?
Thanks