I'm experimenting with lists and the passing of nodes and I ran across a problem. The problem is this: I can access the public members of the derived class, but I cannot access the public members of the base class. I'll post a couple of classes and the one function to keep things simple. Any ideas would be appreciated.
CLASSES:
class terrain {
private:
int terrain_type;
public:
terrain() { terrain_type = 0; }
int GetTerrain() { return terrain_type; }
void SetTerrain( int t ) { terrain_type = t; }
};
class world : public resources, terrain {
private:
int x, y;
public:
world(){ x = y = 0; }
friend ostream &operator<<( ostream &, world );
list<world>::iterator FindProvince( list<world> &, int, int );
int Getx() { return x; }
int Gety() { return y; }
void Setxy( int a, int b ) { x = a; y = b; }
void TraverseMap( list<world> & );
};
void InitializeProvince( world &province, int x, int y )
{
int t_type;
province.Setxy(x,y);
cout << "Enter a t_type: \n";
cin >> t_type;
province.SetTerrain( t_type );
cout << "T: " << province.GetTerrain() << endl;
}
Note that I can use Setxy() but I cannot use GetTerrain() even thought it is a public member of class terrain.