0

我正在学习 boost multiIndex 并且正在关注本教程

问题是我无法使用 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 中。有人可以帮我解释一下吗?

4

3 回答 3

3

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

在 ,之前添加说 using 指令typedef或完全限定multi_index_container, indexed_by, ordered_unique,hashed_unique等。

于 2011-07-10T23:18:57.410 回答
2

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

using namespace boost;
using namespace boost::multi_index;

在给出的代码之前。

于 2011-07-10T23:19:38.740 回答
1

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

于 2011-07-10T23:18:56.180 回答