0

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?

4
Contributors
6
Replies
7
Views
9 Years
Discussion Span
Last Post by Ancient Dragon
0

>>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.

0

A cast to the native type works:

using namespace System;

int main()
{
  Int32^ Account = 100;

  Account = (int)Account + 100;

  Console::WriteLine(Account);
}
0

> 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);
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.