Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the C++/CLI Object^% (caret percent-sign) declaration mean?

Tags:

This apparently is a Google-proof term since I can't get any search engines to not throw away the "extra" characters. I did also look on MSDN in the C++ reference but I can't seem to find the C++/CLI reference because there is nothing in the declarations section on it.

like image 979
Peter Oehlert Avatar asked Feb 18 '11 00:02

Peter Oehlert


1 Answers

It means "pass by reference":

 void bar::foo(Object^% arg) {     arg = gcnew Object;    // Callers argument gets updated  } 

Same thing in C++:

 void foo(Object** arg) {     *arg = new Object;  } 

or C#:

 void foo(out object arg) {      arg = new Object();  } 

C++/CLI doesn't distinguish between ref and out, it does not have the definite assignment checking feature that the C# language has so no need to distinguish between the two. Same in VB.NET, ByRef vs ByVal.

like image 172
Hans Passant Avatar answered Oct 26 '22 23:10

Hans Passant