How do I access abstract private data from derived class without friend or 'getter' functions in C++?
Posted
by
John
on Stack Overflow
See other posts from Stack Overflow
or by John
Published on 2011-02-11T06:51:36Z
Indexed on
2011/02/11
7:25 UTC
Read the original article
Hit count: 180
So, I am caught up in a dilemma right now. How am I suppose to access a pure abstract base class private member variable from a derived class? I have heard from a friend that it is possible to access it through the base constructor, but he didn't explain. How is it possible? There are some inherited classes from base class. Is there any way to gain access to the private variables ?
class Base_button
{
private:
bool is_vis;
Rect rButton;
public:
// Constructors
Base_button();
Base_button( const Point &corner, double height, double width );
// Destructor
virtual ~ Base_button();
// Accessors
virtual void draw() const = 0;
bool clicked( const Point &click ) const;
bool is_visible() const;
// Mutators
virtual void show();
virtual void hide();
void move( const Point &loc );
};
class Button : public Base_button
{
private:
Message mButton;
public:
// Constructors
Button();
Button( const Point &corner, const string &label );
// Acessors
virtual void draw() const;
// Mutators
virtual void show();
virtual void hide();
};
I want to be able access Rect and bool in the base class from the subclass
© Stack Overflow or respective owner