Despot Despondency
December 20th, 2008, 02:36 PM
Hey, I'm trying to write a class, called Country, which consists of a
- string, which is the name of the country
- vector<Country>, which is a vector of the neighboring countries.
At the moment my class looks like this
#ifndef COUNTRY_H
#define COUNTRY_H
#include <vector>
#include <string>
class Country{
public:
Country();
Country(std::string);
std::string getName();
private:
std::string name;
std::vector<Country> neighbours;
};
#endif
Now I want to be able to add neighbours to a country, but I don't want the function to be public.
To be more specific, I am going to create an Atlas class that will create, and store, the countries and read in the neighbours. So is there a way that I can add neighbours to a country from the atlas class, but not from anywhere else.
Any help would be greatly appreciated.
- string, which is the name of the country
- vector<Country>, which is a vector of the neighboring countries.
At the moment my class looks like this
#ifndef COUNTRY_H
#define COUNTRY_H
#include <vector>
#include <string>
class Country{
public:
Country();
Country(std::string);
std::string getName();
private:
std::string name;
std::vector<Country> neighbours;
};
#endif
Now I want to be able to add neighbours to a country, but I don't want the function to be public.
To be more specific, I am going to create an Atlas class that will create, and store, the countries and read in the neighbours. So is there a way that I can add neighbours to a country from the atlas class, but not from anywhere else.
Any help would be greatly appreciated.