String^ str;??????

String^ str;...what does the ^ means...is it same as pointer?
closed account (z05DSL3A)
^ is from C++/cli (.net); it is a handle to an object located on the managed heap.

In C++/cli is similare to a pointer, member selection through a handle (^) uses the pointer-to-member operator (->).

Example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// mcppv2_handle.cpp
// compile with: /clr
ref class MyClass {
public:
   MyClass() : i(){}
   int i;
   void Test() {
      i++;
      System::Console::WriteLine(i);
   }
};

int main() {
   MyClass ^ p_MyClass = gcnew MyClass;
   p_MyClass->Test();

   MyClass ^ p_MyClass2;
   p_MyClass2 = p_MyClass;

   p_MyClass = nullptr;
   p_MyClass2->Test();   
}
Last edited on
Topic archived. No new replies allowed.