错误C2593;程序在VS6下编译,但不在VS10下编译

时间:2010-10-03 04:36:03

标签: c++

  

可能重复:
  error C2593: 'operator =' is ambiguous; Compiled fine on VS6, but I get that error on VS10

我收到以下错误:

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)'

在此代码:

map<string, var> variables;
streamsize sum = 0;

if (sum) {
    variables["$RESULT"] = sum;  // Error 1
    return true;
}

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);

};

与VS6完美编译,但现在我收到了VS10的错误。

0 个答案:

没有答案