使用c ++ 17编译时无法从基类访问成员类型[重复]

问题描述 投票:2回答:1

我有以下代码可以在c ++ 14中成功编译。

template<class T, class ...Args>
class B {
public:
    using AbcData = int;

}

template<typename ...Args>
class D : public B<float, Args...> {
public:
    AbcData m_abc;

}

但是在c ++ 17中编译时,会出现以下错误。

error C2061: syntax error: identifier 'AbcData'

代码有什么问题以及如何解决?

c++ c++14 c++17 variadic-templates
1个回答
2
投票

[当基类B类依赖于模板参数时,即使派生类D在此处键入从AbcData继承的别名B,仅使用AbcData类中的D是不够的。

© www.soinside.com 2019 - 2024. All rights reserved.