F
for.fun
Hi everybody,
I just read the 'shared_ptr' doc from the Boost site (at
http://www.boost.org/libs/smart_ptr/shared_ptr.htm)
There is a point I do not understand !
1/ Suppose you want to create a 'shared_ptr' on the 'MyClass' object
2/ My instanciation code could like this :
shared_ptr<MyClass> spMyClass(new MyClass);
3/ You can note that my Smart Pointer constructor argument is of
'MyClass *' type.
4/ In the Boost documentation, you can find this :
shared_ptr<T> p(new Y);
... which suppose that T and Y can be of different type.
The problem is I can not understand how T can be different from Y.
As the definition says, the Smart Pointer type 'shared_ptr<T>' is a T
Smart Pointer (a smart T *) so the Smart Pointer argument should always
be of type 'T *'
=> Is it possible to have different types for T and Y ? Why and how is
it possible ?
Thanks in advance for your reply.
I just read the 'shared_ptr' doc from the Boost site (at
http://www.boost.org/libs/smart_ptr/shared_ptr.htm)
There is a point I do not understand !
1/ Suppose you want to create a 'shared_ptr' on the 'MyClass' object
2/ My instanciation code could like this :
shared_ptr<MyClass> spMyClass(new MyClass);
3/ You can note that my Smart Pointer constructor argument is of
'MyClass *' type.
4/ In the Boost documentation, you can find this :
shared_ptr<T> p(new Y);
... which suppose that T and Y can be of different type.
The problem is I can not understand how T can be different from Y.
As the definition says, the Smart Pointer type 'shared_ptr<T>' is a T
Smart Pointer (a smart T *) so the Smart Pointer argument should always
be of type 'T *'
=> Is it possible to have different types for T and Y ? Why and how is
it possible ?
Thanks in advance for your reply.