Re: some puzzles
>
> class A {
> ResourceA* ra;
> A(){ra=ra_alloc();}
> virtual ~A(){
> ra_free(ra);
> }
>
> };
>
> class B {
> ResourceB* rb
> B(){rb=rb_alloc();}
> virtual ~B(){
> rb_free(rb);
> }
>
> };
>
> int main(){
> A* obj=new B();
> delete obj; // <-- we want ~B to be called too here!
> return 0;
>
The destructor overloading seems quite strange.
"virtual ~A();" in A, and "virtual ~B();" in B.
have different function names.
|