0

I learned my c++ from Learncpp, which is an excellent website and I would recommend, but it never teaches delegates and events (among other subjects). When I try to learn those subjects I run a lot to the unary postfix ^ operator, for example "String^ str".

This operator is used much like the * for pointers and & for references, so I assume it does something in the same vain. This operator is never really explained anywhere.

Can someone explain to me what is this operator?

Thanks.

Edit: The question has been answered well in the comments. Thanks you!

user1461837
  • 91
  • 2
  • 11
  • Could be https://en.wikipedia.org/wiki/Blocks_(C_language_extension)? – wchargin Dec 01 '15 at 17:13
  • 3
    That operator does not exist in C++. In C++/cli it is indicating a managed pointer. Either way, it is no unary operator. –  Dec 01 '15 at 17:15
  • 3
    In C++, `^` is only used as a binary operator, not a unary operator. Microsoft has a few languages (Managed C++, C++/CLI and C++/CX) that are similar to C++ to some degree, and at least some of them use `^` to indicate a "handle", which (as you've said) is similar to a pointer, but is specific to their garbage collected heap. – Jerry Coffin Dec 01 '15 at 17:15
  • 1
    @user1461837 Managed C++ like C++/CLI uses its onw heap with garbage collector. When it allocates an object in his own heap it returns a reference to this pbject. To denote such a reference C++/CLI uses sign ^. – Vlad from Moscow Dec 01 '15 at 17:18

0 Answers0