无法使用模板编译 std::list 迭代器

发布于 2024-08-14 16:37:06 字数 331 浏览 1 评论 0原文

当我尝试编译它时,出现此错误:

error: expected `;' before 'it'

为什么我无法声明此迭代器?问题出在哪里?

#include <list>

template <typename Z>
class LBFuncBase: public LBBaseBlock<Z>
{
    void Something() {
         std::list<LBBaseBlock< Z >* >::iterator it;
    }
};

When I try to compile this I get this error:

error: expected `;' before 'it'

Why I can't declare this iterator? Where is the problem?

#include <list>

template <typename Z>
class LBFuncBase: public LBBaseBlock<Z>
{
    void Something() {
         std::list<LBBaseBlock< Z >* >::iterator it;
    }
};

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若水般的淡然安静女子 2024-08-21 16:37:06

尝试:

typename std::list<LBBaseBlock< Z >* >::iterator it;

编辑:

参见“为什么有时需要写 typename" 以获得解释。

Try:

typename std::list<LBBaseBlock< Z >* >::iterator it;

Edit:

See "Why do you sometimes need to write typename" for an explanation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文