Garbage Collected Classes

I l @ ve RuBoard

Classes under C++ are usually allocated on the stack or the heap as required. Classes allocated with the new keyword must also be deleted in an orderly fashion to prevent memory leaks. Garbage Collected classes are allocated on the GC heap, are subject to lifetime management and movement by the GC, and will be deleted from the system only after the final reference to them has been released.

The declaration for a Garbage Collected class under managed C++ is as follows :

 __gc class SomeClass { }; 

Under .NET, all classes that have no explicit base class are implicitly derived from System::Object . The managed C++ classes declared with __gc are also added to in this manner by the compiler. This base class has methods that you can override to improve interaction between your GC class and the system. See the System::Object methods in the .NET SDK documentation for more details.

I l @ ve RuBoard


C# and the .NET Framework. The C++ Perspective
C# and the .NET Framework
ISBN: 067232153X
EAN: 2147483647
Year: 2001
Pages: 204

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net