Следующий код дает ошибку времени компиляции:
'
base :: print
': невозможно получить доступ к закрытому члену, объявленному в классе 'base_der
'
Однако я сделал член общедоступным
в производном классе. Почему это не работает?
#include <iostream>
using namespace std;
class base
{
public:
int i;
void print(int i)
{
printf("base i\n");
}
};
class base_der : private base
{
public:
using base::print;
};
int main()
{
// This works:
base_der cls;
cls.print(10);
// This doesn't:
void (base_der::* print)(int);
print = &base_der::print; // Compile error here
}