1

我越来越熟悉 c++/cli。我正在编写一个名为 Locate 的函数和一个名为 Locator 的类。接受输入字符串字典的函数。

Dictionary<String^, array< Byte >^>^ Locate(Dictionary<String^, String^>^ imgParms) 

我试图通过这样做在主函数中调用它:

Locator r;

Dictionary<String^,String^> myDictionary = 
               gcnew Dictionary<String^,String^>();

r.Locate(myDictionary);

但我收到了这个错误

error C3073: 'System::Collections::Generic::Dictionary<TKey,TValue>' : ref class does        
not have a user-defined copy constructor with
          [
              TKey=System::String ^,
              TValue=System::String ^
          ]

任何帮助,将不胜感激。

4

1 回答 1

3
Dictionary<String^,String^> myDictionary = 
               gcnew Dictionary<String^,String^>();

应该

Dictionary<String^,String^>^ myDictionary = 
               gcnew Dictionary<String^,String^>();

^符号可以被认为是类型修饰符,例如*do gcnew 将 a 返回x^给类型 x

于 2012-07-03T16:44:23.017 回答