visual c++ - When to use the __gc keyword on managed C++ classes? -


i have c++ project i've wrapped .net classes using c++/cli. i'm defining wrapper classes in managed c++. need mark classes __gc in order classes garbage collected? or .net framework automatically gc classes since managed classes?

this how declared

public ref class player { 

do need this?

__gc class player { .. } 

the keyword __gc used in previous version (iirc, till vs2003). new context specific keywords (like ref class, value struct) added. newer compilers (vs2005+) understand , suggest use newer keywords. context keyword ref class enough state class managed class. managed classes can allocated using gcnew keyword. compiler raise error of new used managed-classes. vc++ (/clr), stack-semantics avaible.

that means following valid:

public ref class someclass{};  void foo() { someclass cls; // on stack!  } 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -