I stumbled across this code and am too proud to go and ask the author what it means.
Hashtable^ tempHash = gcnew Hashtable(iterators_); IDictionaryEnumerator^ enumerator = tempHash->GetEnumerator();
What is gcnew
and how important is it to use that instead of simply new
? (I'm also stumped by the caret; I asked about that over here.)
No, the garbage collector will delete it.
Managed C++ is a language invented by Microsoft, that compiles to bytecode run by the . NET Framework. It uses mostly the same syntax as C++ (hence the name) but is compiled in the same way as C# or VB.NET; basically only the syntax changes, e.g. using '->' to point to a member of an object (instead of '.
A ref class can have standard C++ types, including const types, in any private , internal , or protected private members. Public ref classes that have type parameters are not permitted. User-defined generic ref classes are not permitted. A private, internal, or protected private ref class may be a template.
gcnew is for .NET reference objects; objects created with gcnew are automatically garbage-collected; it is important to use gcnew with CLR types
gcnew
is an operator, just like the new
operator, except you don't need to delete
anything created with it; it's garbage collected. You use gcnew
for creating .Net managed types, and new
for creating unmanaged types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With