喜欢这段代码
class Try
{
public:
Try() = default;
int i = 0;
};
class B1 : private Try
{
public:
B1() = default;
using Try::Try();
using Try::i;
};
class C1 : public B1
{
public:
Try a; //tell me:'Try' is a private member of 'Try'
void print()
{std::cout << i << std::endl;}
//Access to this I is allowed;
};
Try a 是本地对象,不是 C1 的一部分,为什么会出错?
只要是私有继承的直接基类,就不能在其派生类中定义间接基类对象吗?是因为无法使用构造函数还是其他原因?