4

i have a c# project AAA with the project type “class library", in another c++ project, it add the AAA.DLL in the reference, in the source code

void CTest:OnCallback(OperationCallbackInfo^% oci)

OperationCallbackInfo is class defined in AAA.dll

my question is: what does the symbol ^ and % mean in the parameter?

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Carlos Liu
  • 2,348
  • 3
  • 37
  • 51
  • 3
    @Brendan Long: It's *not* a duplicate. `^%` isn't the same as `^` on its own (though it's probably no surprise that they are related). – Jerry Coffin Feb 15 '11 at 03:26

2 Answers2

7

It means what you have isn't really C++ at all, but C++/CLI, Microsoft's proprietary version of the language for .NET.

If memory serves, ^% is the syntax for a "tracking reference". It means (at least pretty much) the same as ref does in C#. From a C++ point of view, it's pretty much the same as defining a parameter as a reference to a pointer.

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111
  • Not quite. The % alone signifies a tracking reference - see https://docs.microsoft.com/en-us/cpp/extensions/tracking-reference-operator-cpp-component-extensions?view=msvc-160 or https://web.archive.org/web/20121129100839/http://msdn.microsoft.com/en-us/library/8903062a(VS.80).aspx . The '^' is a "handle", kind of like a pointer to an object on the managed heap. See https://web.archive.org/web/20150117095313/http://msdn.microsoft.com/en-us/library/yk97tc08(VS.80).aspx . So ^% is indeed like a reference to a pointer, where the pointer and the object pointed to are both on the managed heap. – AJM Mar 02 '21 at 16:42
  • Incidentally, if you dereference a handle (^), the result will be a tracking reference (%). – AJM Mar 02 '21 at 16:42
0

According to this question, it's a "handle", which is a reference (similar to a pointer) in managed C++.

Community
  • 1
  • 1
Brendan Long
  • 53,280
  • 21
  • 146
  • 188