Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   __gc class (http://www.programmingforums.org/showthread.php?t=10906)

hbe02 Aug 1st, 2006 8:30 AM

__gc class
 
if i create a managed C++ class :
:

__gc class MyClass
And say one of its members is a pointer to a string
:

string * MyString
Does MyString have to be declared a __gc string pointer or i need not do that as the class is managed and members dont have to be.
One more thing on managed c++. Garbage collection happens when a pointer or referenced object "falls out of scope" exactly what does that mean in terms of memory management and when does it occur in a program.
thanks ..

JimmyJim Aug 1st, 2006 8:50 AM

Garbage Collection is where when a object on the heap that no longer has any references to it remaining it is deleted automatically. This avoids the need to manually delete in your code.

There are some verious ways this can be achieved. The most common is where the heap is copied to a new heap and any objects on the heap that have no references remaining will be left behind and so will be removed. There are machanisms to figure out if there is circular references and remove objects that refer to other objects on the heap with no references in the scope of your program.

Managed C++ is a dire language and i would keep well away. MS have replaced it with C++/CLI which comes with .net 2.0. Its much improved though i still dont really see the use of it. If you are a C++ developer converting to .net its probably a better idea to go with C# as its the number one language on .net.

I have not looked at managed C++ in quite a while so i cant remember the syntax so i will avoid spreading rubbish. If you need C++ for .net use C++/CLI its 10 times better, or use C# which is far far more straight forward.

hbe02 Aug 1st, 2006 4:36 PM

hey thanks for the helpfull feedback on garbage collection JimmyJim ..
I am currently learning c++.net to get into GUI's and connecting to & operating on SQL databses.. But will convert to C#.net next spring.. :D


All times are GMT -5. The time now is 12:18 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC