• 0

error C2593: 'operator +=' is ambiguous (watch my


Question

How come that this line will compile in VS 6.0 but not in VS 7.0?

strOut += strData[iPos] ^ strKey[iKeyPos++];

strOut, strData and strKey are Cstring.

IPos and iKeyPos is int.

I got the compiler error: C2593: 'operator +=' is ambiguous

Thanks

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Ummm... need a bit more information here. Context would be helpful; contents of the strings would be even more helpful. Also, IIRC, the '^' operator is for exponential operations, which don't apply to strings.

Link to comment
Share on other sites

  • 0
Ummm... need a bit more information here. Context would be helpful; contents of the strings would be even more helpful. Also, IIRC, the '^' operator is for exponential operations, which don't apply to strings.

I didn't think you could do powers that way. I thought you had to do pow(base,exp) which is in cmath. I'm not sure what the ^ operator does to strings either. Possibly you mean +?

Isnt it =+ ?

And no, it is +=.

Edited by kjordan2001
Link to comment
Share on other sites

  • 0

I know ^ isn't an exponent operator, because I keep trying it and I get the same results every time :pinch:

Can you treat strings as arrays in .NET? :unsure: I've never tried :s

Link to comment
Share on other sites

  • 0

Well, this isn't .NET code. He's trying to compile in VS6 and VS7, which suggests that it's native code (also he said they're CStrings).

And yes you can. The .NET String class has an indexer which you can use to get individual characters.

Link to comment
Share on other sites

  • 0

Since strData is a CString, strData[somePosition] would equate to a char or wchar_t, depending on if you're using UNICODE or not. So according to your code, the two char values should be XOR'ed, and appended to strOut.

I can't really see any error in your code, other than maybe the operator += call is conflicting with the others.

try this:

strOut += (TCHAR)(strData[iPos] ^ strKey[iKeyPos++]);

hope that helps,

bwx

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.