gpt4 book ai didi

c++ - 为什么 clang 不允许派生类调用 protected 基函数?

转载 作者:太空宇宙 更新时间:2023-11-04 14:33:52 25 4
gpt4 key购买 nike

<分区>

template<int N>
struct B
{
protected:
void f() {}
};

template<int N>
struct A : B<N>
{
A()
{
this->f(); // ok
f(); // error : use of undeclared identifier 'f'
}
};

int main()
{
A<8> a;
}

我的 C++ 编译器是 clang 3.8。

为什么 clang 不允许派生类调用 protected 基函数?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com