2

I'm reading a program in (.NET) C++ made by someone else, and I can't figure out what this means:

BinaryWriter^ file = gcnew BinaryWriter( File::Open( "Data.al", FileMode::OpenOrCreate ));

What DOES the ^ do in this sentence?

and what about this:

void GetEEDataRx(array<Byte> ^%EE)

What is the purpose of the ^%

juanchopanza
  • 223,364
  • 34
  • 402
  • 480
Gabriel Matusevich
  • 3,835
  • 10
  • 39
  • 58

1 Answers1

7

This is C++/CLI.

The ^ is declaring a managed pointer (as opposed to a raw pointer using *). The BinaryWriter object is being allocated with gcnew instead of new, so it will be garbage-collected when it is not being used anymore.

The ^% is a tracking reference. It is the equivalent of the C# ref keyword.

You can read the documentation to learn more about C++/CLI, now that you know what it is.

Raymond Chen
  • 44,448
  • 11
  • 96
  • 135
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770