不能在另一个项目的dll中使用一个类的typedef

时间:2011-05-03 15:48:59

标签: .net c++ dll typedef

我已经写了一个dll,其中我有namespace VT的女巫等级public ref class Database,我有一个typedef:

public:
        typedef System::Collections::Generic::Dictionary <System::String^, Database^>         SubkeyDictionary;
        typedef System::Collections::Generic::Dictionary <System::String^, System::Object^>   ValueDictionary;
        typedef System::Collections::Generic::KeyValuePair <System::String^, Database^>       SubkeyKeyValuePair;
        typedef System::Collections::Generic::KeyValuePair <System::String^, System::Object^> ValueKeyValuePair;

当我将我的dll添加到另一个项目并写VT ::我看不到我的typedef,为什么???

2 个答案:

答案 0 :(得分:1)

排版更像是别名而不是实际类型,我稍后会检查,但我怀疑这不会作为可以从其他程序集中使用的.NET类型公开。

然而,一切都不会丢失。您可以执行以下操作,而不是使用排版

public:
  ref class SubkeyDictionary : public System::Collections::Generic::Dictionary <System::String^, Database^> {};
....

这将声明您可以引用的实际类型。

答案 1 :(得分:0)

typedef在类中,而不是命名空间。写

VT::Database::

应该这样做。