Hello George,
Since I do not have the latest g++, I have some basic questions.
I thought auto_ptr<B> is a smart pointer 'B*' and auto_ptr<B*> is
a smart pointer 'B**'. Is this your intention?
class auto_ptr<B> {
B* ptr;
bool owns;
...
};
class auto_ptr<B*> {
B** ptr;
bool owns;
};
Second, will you explain how 'new X' is implicitly converted to
auto_ptr<Base1*>? Is it X* to base class pointer Base1* and then
Base1* to auto_ptr<Base1> by constructor?
I see FactoryFunction is not template. Is it possible to use
explicit conversion in it. Looks like it is possible.
auto_ptr<Base1> FactoryFunction() { return auto_ptr<Base1>(new X); }
Thank you
Masaharu Goto
>class X: public Base1 {};
>
>class Base1: public TObject {};
>
>auto_ptr<Base1 *> FactoryFunction() { return new X; }
>
>and in CINT:
>
>auto_ptr<Base1 *> p = FactoryFunction();
>auto_ptr<TObject *> localobjs[10];
>// localobjs is a polymorphic list of resources I own to be cleaned up
>// appropriately. I'm not using an STL container here because they don't
>// work well with auto_ptr :(
>localobjs[2] = p;
>
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:18 MET