更新时间:2023-02-14 22:43:26
I think that the thing you are trying to do should looks like this:
#include <iostream>
using namespace std;
class X
{
private:
int var;
protected:
virtual void fun ()
{
var = 10;
cout << "\nFrom X" << var;
}
};
class Y : public X
{
private:
int var;
public:
virtual void fun ()
{
var = 20;
cout << "\nFrom Y" << var;
}
void call ()
{
fun ();
X::fun ();
}
};
That way you can invoke hiden member from your base class. Otherwise you have to add friend X as it was pointed in other post.