Migrating from VC++ 6.0 to VC++ 2005

G

Guest

Hi,

After migrating my application from VC++ 6.0 to VC++ 2005, I receive the
error C2593 'operator +=' is ambiguous.

It refers to the following line:

Name += pManager->GetAgentName();

where Name is a string and GetAgentName also returns a string.

Please suggest.

Regards,
Arjun
 
N

Nathan Mates

After migrating my application from VC++ 6.0 to VC++ 2005, I receive the
error C2593 'operator +=' is ambiguous.
Name += pManager->GetAgentName();
where Name is a string and GetAgentName also returns a string.

The concept of 'string' in C++ is a very vague and overloaded
concept. Do you mean a char*, a std::string, a CString (ATL/MFC), a
tstring? [Or any other number of custom C++ string classes which may
exist in your code.] Or the unicode versions of any/all of those?

My recommendation: find out what the types *really* are in the line
you posted above. That'll usually help point you in the right
direction, as I bet you'll find that they're different.

Nathan Mates
 
G

Guest

HI Nathan,

Its a CString.

CString MachineName;

Regards,
Arjun


Nathan Mates said:
After migrating my application from VC++ 6.0 to VC++ 2005, I receive the
error C2593 'operator +=' is ambiguous.
Name += pManager->GetAgentName();
where Name is a string and GetAgentName also returns a string.

The concept of 'string' in C++ is a very vague and overloaded
concept. Do you mean a char*, a std::string, a CString (ATL/MFC), a
tstring? [Or any other number of custom C++ string classes which may
exist in your code.] Or the unicode versions of any/all of those?

My recommendation: find out what the types *really* are in the line
you posted above. That'll usually help point you in the right
direction, as I bet you'll find that they're different.

Nathan Mates
--
<*> Nathan Mates - personal webpage http://www.visi.com/~nathan/
# Programmer at Pandemic Studios -- http://www.pandemicstudios.com/
# NOT speaking for Pandemic Studios. "Care not what the neighbors
# think. What are the facts, and to how many decimal places?" -R.A. Heinlein
 
N

Nathan Mates

After migrating my application from VC++ 6.0 to VC++ 2005, I receive the
error C2593 'operator +=' is ambiguous.
Name += pManager->GetAgentName();
where Name is a string and GetAgentName also returns a string.
The concept of 'string' in C++ is a very vague and overloaded
concept. Do you mean a char*, a std::string, a CString (ATL/MFC), a
tstring? [Or any other number of custom C++ string classes which may
exist in your code.] Or the unicode versions of any/all of those?
My recommendation: find out what the types *really* are in the
line you posted above. That'll usually help point you in the right
direction, as I bet you'll find that they're different.
Its a CString.
CString MachineName;

First, don't top-post. English is read left-to-right,
top-to-bottom. Trim off your replies to be just what you're
responding to.

Next, why bring up 'MachineName' when is not found in the code
snippet you gave above -- it's 'Name' and whatever GetAgentName()
returns. Also, note that I said to investigate the type*S* in that
line. Not 'type'. Plural. In your line about 'Name +=
blah->GetAgentName()', you need to look into the type*S* of the left
and right sides of that.

Nathan Mates
 
B

Ben Voigt

Nathan Mates said:
After migrating my application from VC++ 6.0 to VC++ 2005, I receive
the
error C2593 'operator +=' is ambiguous.
Name += pManager->GetAgentName();
where Name is a string and GetAgentName also returns a string.
The concept of 'string' in C++ is a very vague and overloaded
concept. Do you mean a char*, a std::string, a CString (ATL/MFC), a
tstring? [Or any other number of custom C++ string classes which may
exist in your code.] Or the unicode versions of any/all of those?
My recommendation: find out what the types *really* are in the
line you posted above. That'll usually help point you in the right
direction, as I bet you'll find that they're different.
Its a CString.
CString MachineName;

First, don't top-post. English is read left-to-right,
top-to-bottom. Trim off your replies to be just what you're
responding to.

Next, why bring up 'MachineName' when is not found in the code
snippet you gave above -- it's 'Name' and whatever GetAgentName()
returns. Also, note that I said to investigate the type*S* in that
line. Not 'type'. Plural. In your line about 'Name +=
blah->GetAgentName()', you need to look into the type*S* of the left
and right sides of that.

Of course, this is SO fundamental to solving a "ambiguous function" error
that the compiler really should have told you that, along with the possible
matches it found. In fact, I think VC++ 2005 does exactly that.

Please cut+paste the following few lines from the compiler output, where it
gives the argument types along with the candidate functions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top