Does the ^ symbol replace C#'s “ref” in parameter passing in C++/CLI code?

后端 未结 5 1911
轻奢々
轻奢々 2020-12-13 15:25

In C#, passing by reference is:

void MyFunction(ref Dog dog)

But in C++/CLI code examples I have seen so far, there is no use of ref<

5条回答
  •  猫巷女王i
    2020-12-13 16:08

    3 Types in C++/CLI :

    1. Handle Type (^): Handle contain address of variable but which can be updated by runtime if it has to move variable around to maximize available free memory.
      Example: Person ^pp = gcnew Person(); // gcnew in C++/CLI is similar to new in C++.

    2. Reference Type (%): Reference alias of a variable. % in C++/CLI is Similar to & in C++.
      Example: int %ri = i; // ri is reference alias for i.
      Person %rPerson = *pp; // pp from point number 1

    3. Array Type ([]):

提交回复
热议问题