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?

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

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

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

A cast to the native type works:

using namespace System;

int main()
{
  Int32^ Account = 100;

  Account = (int)Account + 100;

  Console::WriteLine(Account);
}

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.