Please help me. I read many books and they talk: protected member can be accessed from member in same class, friend of own class, derivative class and friend of derivative class. I write code on codeblocks, all things are right, but friend of derivative class is wrong. Why ? Please help me. Here's my code ------------------ Code: class Polygon{ protected: int w, h; public: void setValue(int w, int h){ this->w = w; this->h = h; } }; class Rectangle:public Polygon{ public: int area(){ return w*h; } friend int area1(); }; int area1(){ return w*w; }
What is "w" here?? w is not recognized..pass the object of Rectangle in area1 and then access "w" ...