[Gc] More doubts: (beginner)

Renato Tegon Forti renato.trinity at novaamerica.net
Tue Jan 25 04:17:20 PST 2005


Hi to all,

I use C++, 
I saw the gc_cpp.h file, and I have some doubts. Can anyone help-me to
understand?

1- If I use: 

class A {.};
--------------------------------------------------
A* a = new A;  //-> a is uncollectable. OK?
A* a = new (GC) A;  //-> a is collectable. OK?

OR

int *I = new (GC) int; I is collectable. OK?


2- If I use:

class A: public gc {...};

A* a = new A;  //-> a is collectable. OK?
A* a = new (NoGC) A;  //-> a is uncollectable. OK?

Now, if I have:

class B: public A {...};

B* b = new B; //-> b is collectable ????????

If I have a class structure, like this:

	A (: public gc)
	|
-------------
|	|	|
B	C	D
		|
		------
		|	|
		E	F

And I derive A of gc, all derived class's now is collectable?

int main()
{
	B *b = new B;
	E *e = new E;
	...
	// delete b; // I don't need more this. (b now is collectable) OK?
	// delete e; // I don't need more this. (e now is collectable) OK?
}


3 - Constructors and Destructor:

Constructor and destructors are called in natural order?

B* b = new B; //-> Constructor is called in creation?, and destructor is
called when 'b' is not more needful, and GC destroy it? 


4 - Arrays:

Arrays work the same way?

A *a = new A[10]; (???)
...


5 - I don't understand this --> A* a = ::new (GC, MyCleanup) A;

When I should use this: A* a = ::new (GC, MyCleanup) A; I don't understand,
Can you explain-me in detail?

When the object is inaccessible?




6 - What more tricks I need know to use GC correctly in my C++ applications?


Thanks to all.
This GC is excellent work...




More information about the Gc mailing list