error C2593: 'operator =' is ambiguous; Compiled fine on VS6, but I get that error on VS10
I get the following error:
1>c:\documents and settings\krzys\desktop\desktop icons\ollydbg\plugins\odbgscript\OllyLangCommands.cpp(3602): error C2593: 'operator =' is ambiguous
1> c:\documents and settings\krzys\desktop\desktop icons\ollydbg\plugins\odbgscript\var.h(45): could be 'var &var::operator =(const long double &)'
1> c:\documents and settings\krzys\desktop\desktop icons\ollydbg\plugins\odbgscript\var.h(42): or 'var &var::operator =(const int &)'
1> c:\documents and settings\krzys\desktop\desktop icons\ollydbg\plugins\odbgscript\var.h(41): or 'var &var::operator =(const ulong &)'
1> while trying to match the argument list '(var, std::streamsize)'开发者_StackOverflow
At this code:
map<string, var> variables;
streamsize sum = 0;
if (sum) {
variables["$RESULT"] = sum; // Error 1
return true;
}
and
class var
{
public:
ulong dw;
string str;
long double flt;
vtype vt;
bool isbuf;
int size;
var();
var(const var& rhs);
var(string& rhs);
var(ulong rhs);
var(int rhs);
var(long double rhs);
// less than zero this < rhs
// zero this == rhs
// greater than zero this > rhs
int compare(const var& rhs) const;
int compare(const string& rhs) const;
int compare(const ulong& rhs) const;
int compare(const int& rhs) const;
int compare(const long double& rhs) const;
string strclean(void);
string strbuffhex(void);
string strbuff(void);
var& operator=(const var& rhs);
var& operator=(const string& rhs);
var& operator=(const ulong& rhs); // Error 4
var& operator=(const int& rhs); // Error 3
var& operator=(unsigned short& rhs);
var& operator=(unsigned char& rhs);
var& operator=(const long double& rhs); // Error 2
var& operator+=(const var& rhs);
var& operator+=(const string& rhs);
var& operator+=(const ulong& rhs);
var& operator+=(const int& rhs);
var& operator+=(const long double& rhs);
void resize(ulong newsize);
};
Compiled perfectly with VS6, but now I'm getting this error with VS10.
Check sum's type and variables's methods. There's a chance they've added new operator= overloads in the switch from VS6 to VS2010.
Your variables
map holds values of type var
. sum
isn't a var
, so a conversion needs to be made.
The streamsize
type in VC6 is a simple int
and the var
class will convert that to a var
type implicitly.
In VS10, streamsize
is an __int64
, which you have no implicit conversion to a var
for.
精彩评论