【问题标题】:typedef in VC++ & boostVC++ 和 boost 中的 typedef
【发布时间】:2011-07-10 23:10:13
【问题描述】:

我正在学习 boost multiIndex,我正在关注 this tutorial

问题是我无法使用 Visual Studio 2008 编译散列索引部分(该页面上的第一个代码块)中的代码 :(

每次尝试,c++编译器都会报错:

main.cpp(19) : error C2143: syntax error : missing ';' before '<'
main.cpp(19) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

这些错误发生在上面显示的代码块中第 19 行的 typedef 中。有人可以帮我解释一下吗?

【问题讨论】:

    标签: visual-studio-2008 visual-c++ boost boost-multi-index


    【解决方案1】:

    该示例中的代码有一个隐含的 using 指令 ​​-- using namespace boost::multi_index;

    要么在 typedef 之前添加说 using 指令,要么完全限定 multi_index_containerindexed_byordered_uniquehashed_unique 等。

    【讨论】:

    • 觉得自己好傻,非常感谢,确实是我的问题:)
    【解决方案2】:

    他们的代码示例不包含必要的命名空间,我认为这是您的问题。尝试添加

    using namespace boost;
    using namespace boost::multi_index;
    

    在给出的代码之前。

    【讨论】:

      【解决方案3】:

      这是一个命名空间问题。你需要一个 boost:: 在 multi_index_container 和 indexed_by 以及你从 boost 中提取的所有其他内容之前。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-07-07
        • 1970-01-01
        • 2011-03-04
        • 1970-01-01
        • 2011-12-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多