I have a class A which has a class B as a private member variable.Class b also has a class C as a private member variable.(A->B->C).. I am trying to call a method which has an implementation in class C but i keep getting an erroR saying the object of class C which i declared in class B is private when i try to write a method in class A. e.g B->C->setGreeting();class Country
{
public:
void setPoints(int x,int y);
private: City * city;
}
// i am having problems here with error Point * city p is private
void Country::setPoints(int x,int y){
city->p->setPoints(x,y);
}
class City
{
public:
City();
virtual ~City();
protected:
private:
Point *p;
};
class Point
{
public:
Point();
virtual ~Point();
void setPoints(int x,int y);
protected:
private:
int x;
int y;
};
void Point::setPoints(int xp,int yp){
x=xp;
y=yp;
}