2

I understand in C , the operator ^is used for bit-wise EX-OR. In one of the C++ code I saw the following lines where this operator is used:

 using namespace System::Threading;
 public ref class Expert : public System::Windows::Forms::Form
{
    int i ;
        float a ;


public:
    int count;
    Thread^ th;

     }

What is the meaning of ^ here ?

john
  • 7,897
  • 29
  • 27
gpuguy
  • 4,607
  • 17
  • 67
  • 125
  • 2
    That isn't C++, it's C++/CLI which is a Microsoft extension of C++. – john Nov 16 '12 at 12:56
  • 2
    It means that the code isn't C++, but a somewhat similar language from Microsoft. (I forget the name of the language, but it has C++ in it.) – James Kanze Nov 16 '12 at 12:56
  • In C++ (as in C) it is the bitwise exclusive-or (XOR) operator. In the context of your question, it is something completely different and not C++. – juanchopanza Nov 16 '12 at 13:06

4 Answers4

5

That is not C++, it's a variant of C++ named C++/CLI and is a Microsoft extension to make managed .NET applications in C++.

The ^ when used like that is do denote managed pointers, i.e. memory that can be garbage collected.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
3

That's a .net reference type, in C++/CLI! That is, Expert::th is a reference to an instance of System.Threading.Thread (or null). You can also tell it's C++/CLI by the fact it's inheriting from a .net class.

Adam Wright
  • 48,938
  • 12
  • 131
  • 152
3

That's not C++, that's C++/CLI. The ^ stands for "handle" and is like a managed pointer.

Kos
  • 70,399
  • 25
  • 169
  • 233
3

You will also see the ^ ("hat") symbol in C++/CX, which is C++ with a set of extensions that helps support Windows 8 (WinRT) development.

http://en.wikipedia.org/wiki/C%2B%2B/CX

http://en.wikipedia.org/wiki/WinRT#C.2B.2B_.28WRL.2C_Component_Extensions.29

Inisheer
  • 20,376
  • 9
  • 50
  • 82