The following error appears in Visual Studio 2008: error C2248: "City :: City": cannot access the private member declared in the "City" class. It seems that the constructor cannot access members of its class. Any idea what is going on? Here is the code:
I have it:
template<class T> class Tree{...}
And this class:
class Town{
Town(int number):number(number){};
...
private:
int number;
};
What is used in this class:
class Country{
public:
StatusType AddTown(Shore side, int location, int maxNeighborhoods);
private:
Tree<Town> towns[2];
...
}
And here is the AddTown function:
StatusType Country::AddTown(Shore side, int location, int maxNeighborhoods){
if (maxNeighborhoods<0 || location<0){
return INVALID_INPUT;
}
Town* dummy= new Town(location);
if (towns[side].find(*dummy)!=NULL){
delete dummy;
return FAILURE;
}
SouthBorder* dummyBorder;
(side==NORTH)?dummyBorder=new SouthBorder(location,0):dummyBorder=new SouthBorder(0,location);
if (southBorders.find(*dummyBorder)!=NULL){
delete dummyBorder;
return FAILURE;
}
towns[side].add(*dummy);
delete dummyBorder;
return SUCCESS;
}
source
share