2

私はデータ構造を使用しますbimap

typedef boost::bimap< std::string, int > hash_bimap;
typedef hash_bimap::value_type position;
hash_bimap perm;

メインファイルで正常に動作します。ただし、ヘッダーファイルで使用して、他の.cppファイルでアクセスできるようにすることに興味があります。

externmy.hようにしようとすると

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< std::string, int > hash_bimap;

4

1 に答える 1

3

(kfsoneのコメントを詳しく説明しています)typedefsはexternである必要はなく、実際の変数だけです:

typedef boost::bimap< std::string, int > hash_bimap;
typedef hash_bimap::value_type position;
extern hash_bimap perm;
于 2016-05-19T16:52:07.013 に答える