Understanding String ^ in C ++. Net

I remember that somewhere there the “^” operator is used as a pointer operator in C ++ managed code. Therefore, should "^" be equivalent to the rule of the operator *?

Assuming my understanding is correct, when I started to understand .Net and encoded some sample programs, I came across some code:

String ^username; //my understanding is you are creating a pointer to string obj
.
.         // there is no malloc or new that allocates memory to username pointer
.
username = "XYZ"; // shouldn't you be doing a malloc first??? isn't it null pointer

I am having trouble understanding this.

+5
source share
3 answers

String^- a pointer to a managed pile, aka pen. Pointers and pens are not interchangeable.

new . , gcnew .

username = "XYZ" - -.

username = gcnew String(L"XYZ");
+8

, .

, .

+3

If you think you are ^like shared_ptr, you will be close to the truth.

+2
source

All Articles