Reputation: 197
I am writing a program in c++/cli and it is giving me the error: Error C2872: 'String' : ambiguous symbol
I am using String as part of a function:
Dictionary<String^, List<array< Byte >^>^>^ FalseTrigg(Dictionary<String^, String^>^ imgParms, bool windowOn)
Below is the overall program. Thanks for any help.
#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)
{}
};
Upvotes: 1
Views: 5464
Reputation: 27864
You've got two definitions for the class String, and the compiler doesn't know which one you need. There should be more lines to the error message, which will list the various 'string' classes it found.
I'm not exactly sure which definitions it's finding, since std::string
is supposed to be a lowercase "s", and you're using an uppercase "S".
In your method definition, just replace String^
with System::String^
, and you should be good.
Alternatively, you could figure out which 'string' classes it's finding, and change your using namespace
directives to not use the namespace that contains the other string class. You could also use a typedef to make String
explicitly refer to System::String
.
Upvotes: 3
Reputation: 1683
It looks like you have included the definition for String twice.
#include <errno.h>
#include <vector>
#include <string> //-> First time
#include <iostream>
#include <sstream>
#include <string> //-> Second time
#include <fstream>
Upvotes: -1