我正在用c++/cli写一个程序,它给我一个错误: Error 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)
{}
};发布于 2013-05-01 02:49:00
你有两个类字符串的定义,编译器不知道你需要哪一个。错误消息应该有更多的行,它将列出它找到的各种'string‘类。
我不确定它找到了哪些定义,因为std::string应该是小写的"s",而您使用的是大写的"S“。
在您的方法定义中,只需将String^替换为System::String^,就可以了。
或者,您可以找出它正在查找哪些“string”类,并更改您的using namespace指令以不使用包含另一个string类的名称空间。您还可以使用类型定义函数来使String显式地引用System::String。
发布于 2013-05-01 02:40:15
看起来您已经包含了两次字符串的定义。
#include <errno.h>
#include <vector>
#include <string> //-> First time
#include <iostream>
#include <sstream>
#include <string> //-> Second time
#include <fstream>https://stackoverflow.com/questions/16306728
复制相似问题