954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

binary '+' : 'System::Int32 ^' does not define this operator or a conversion... ??

binary '+' : 'System::Int32 ^' does not define this operator or a conversion to a type acceptable to the predefined operator.

I have this error in this line :

Account = Account + 100;


Account is pointer to Account i main class.

some stange is this, that this code:

Account = 200

is working...
Someone can help?

mariaczi_pl
Newbie Poster
15 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

Can you post your code please? It's unlikely that we can help you if you don't.

Alex Edwards
Posting Shark
972 posts since Jun 2008
Reputation Points: 392
Solved Threads: 109
 

>>Account = Account + 100;
If Account is a pointer, then that line is attempting add 100 to the pointer. I doubt that is your intent. We can't tell from your post what exactly you want that line to do.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

I want add 100 to value, not to pointer...

mariaczi_pl
Newbie Poster
15 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

A cast to the native type works:

using namespace System;

int main()
{
  Int32^ Account = 100;

  Account = (int)Account + 100;

  Console::WriteLine(Account);
}
Radical Edward
Posting Pro
545 posts since May 2008
Reputation Points: 361
Solved Threads: 97
 

> If Account is a pointer to an integer
The error suggests that Account is a System::Int32 reference object. Dereferencing will work too, but Edward doesn't like that as much as an explicit cast. Int32 is a value type anyway, I don't know why mariaczi_pl is using a reference when this works as expected:

using namespace System;

int main()
{
  Int32 Account = 100;

  Account = Account + 100;

  Console::WriteLine(Account);
}
Radical Edward
Posting Pro
545 posts since May 2008
Reputation Points: 361
Solved Threads: 97
 

Ed: you read AD's post before AD deleted it. AD doesn't know a hill of beans about managed code.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You