After looking at compile errors because I was not overriding this function ( although being convinced that I was) I have a query for all you C++ buffs in the audiance. What does the ^ do in the following line.

virtual System::Object ^ Clone(void) override;

I know this is quite possably a stupid question and for that I am quite sorry.

Recommended Answers

All 2 Replies

Ok, Replying to my own thread here, But I have had a look around the net and from what I can tell it refers to a reference to a managed type in .NET. I may be wrong ( since I have seen nothing that has said this yet )

As u said........ a caret [^] is a managed reference (usually called a handle in C++/CLI) is a reference to a managed .NET object. Managed object's lifetimes that are controlled by the .NET garbage collection system which needs to be able to track all references to managed objects. Having separate syntax for managed references / handles and regular native references helps makes this distinction explicit in the code and avoid confusion between managed / garbage collected .NET types and unmanaged native types whose lifetimes must still be managed explicitly by the programmer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.