首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不明确的符号串

不明确的符号串
EN

Stack Overflow用户
提问于 2013-05-01 02:36:03
回答 2查看 4.6K关注 0票数 1

我正在用c++/cli写一个程序,它给我一个错误: Error C2872:'String‘:歧义符号

我使用字符串作为函数的一部分:Dictionary<String^, List<array< Byte >^>^>^ FalseTrigg(Dictionary<String^, String^>^ imgParms, bool windowOn)

下面是整个程序。谢谢你的帮助。

代码语言:javascript
复制
 #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) 
  {}
};
EN

回答 2

Stack Overflow用户

发布于 2013-05-01 02:49:00

你有两个类字符串的定义,编译器不知道你需要哪一个。错误消息应该有更多的行,它将列出它找到的各种'string‘类。

我不确定它找到了哪些定义,因为std::string应该是小写的"s",而您使用的是大写的"S“。

在您的方法定义中,只需将String^替换为System::String^,就可以了。

或者,您可以找出它正在查找哪些“string”类,并更改您的using namespace指令以不使用包含另一个string类的名称空间。您还可以使用类型定义函数来使String显式地引用System::String

票数 3
EN

Stack Overflow用户

发布于 2013-05-01 02:40:15

看起来您已经包含了两次字符串的定义。

代码语言:javascript
复制
#include <errno.h>
#include <vector>
#include <string>  //-> First time
#include <iostream>
#include <sstream>
#include <string>  //-> Second time
#include <fstream>
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16306728

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档