2013-04-30 116 views
1

我在C++/CLI編寫一個程序,它是給我的錯誤: 錯誤C2872:「串」:不明確的符號曖昧的符號串

我使用String作爲函數的一部分: Dictionary<String^, List<array<Byte>^>^>^ FalseTrigg(Dictionary<String^, String^>^ imgParms, bool windowOn)

以下是整個程序。謝謝你的幫助。

#include <errno.h> 
#include <vector> 
#include <string> 
#include <iostream> 
#include <sstream> 
#include <string> 
#include <fstream> 

#pragma managed(push, off) 

#include "cv.h" 
#include "highgui.h" 
#include <stdio.h> 
#include "opencv2/core/core.hpp" 
#include "opencv2/features2d/features2d.hpp" 
#include "opencv2/highgui/highgui.hpp" 
#include "opencv2/nonfree/nonfree.hpp" 
#include <opencv2/nonfree/features2d.hpp> 

#pragma managed(pop) 

using namespace cv; 
using namespace std; 
using namespace System; 
using namespace System::Collections::Generic; 
using namespace System::Runtime::InteropServices; 


public ref class FalseTrig 
{ 
    public: 
    FalseTrig() { } 
    ~FalseTrig() { } 

    Dictionary<String^, List<array<Byte>^>^>^ FalseTrigg(Dictionary<String^, String^>^ imgParms, bool windowOn) 
    {} 
}; 

回答

-1

它看起來像您已經爲字符串定義的兩倍。

#include <errno.h> 
#include <vector> 
#include <string> //-> First time 
#include <iostream> 
#include <sstream> 
#include <string> //-> Second time 
#include <fstream> 
+0

''頭文件具有適當的包括警衛。包括它兩次不會傷害任何東西。 – 2013-04-30 18:51:05

2

對於類String有兩個定義,編譯器不知道你需要哪一個。錯誤消息應該有更多的行,它會列出它找到的各種'字符串'類。

我不確定它找到了哪些定義,因爲std::string應該是一個小寫的「s」,而您使用的是大寫的「S」。

在你的方法定義,只是System::String^取代String^,你應該是好的。

或者,你可以找出它找到的'string'類,並將using namespace指令更改爲不使用包含其他字符串類的名稱空間。您也可以使用typedef使String明確指向System::String