Search code examples
c++c++-cli

I see many examples of C++ with the use of "Foo ^ bar" - what is "^"?


Is that .NET related? It appears to be a pointer of some sort, what is the difference?

Edit:

I actually know it is the XOR operator, but look at this example from this page.

void objectCollection() {
    using namespace System::Collections;

    ArrayList ^as = gcnew ArrayList;

    //... 
}

What is this?

Thanks.


Solution

  • I'm assuming that you're looking at constructs of the form:

    Foo ^bar = gcnew Foo();
    

    You're right, in .NET it is a pointer-"like" type and is part of C++/CLI, not but not standard ISO C++.

    It's a reference to a garbage-collected, managed .NET object as opposed to a regular, unmanaged C++ object.

    As the other poster suggest, outside the .NET world or in a non-object creation context, it is the XOR operator.