【发布时间】:2016-05-19 16:40:42
【问题描述】:
我使用一个数据结构bimap
typedef boost::bimap< std::string, int > hash_bimap;
typedef hash_bimap::value_type position;
hash_bimap perm;
它在主文件中运行良好。但是,我有兴趣在头文件中使用它,以便在任何其他 .cpp 文件中访问它。
当我尝试在my.h 中实现extern 就像
extern typedef boost::bimap< std::string, int > hash_bimap;
extern typedef hash_bimap::value_type position;
extern hash_bimap perm;
“hash_bimap”声明中的说明符冲突 extern typedef boost::bimap hash_bimap;
【问题讨论】:
-
typedef 没有声明链接器可以看到的任何内容,因此您不需要/不能将其设为外部。
-
@kfsone 谢谢!!如何使其可供其他
.cpp文件访问 -
只需在另一个
cpp文件中包含带有 typedef 的标题。
标签: c++ boost-bimap