shared_ptr p(new Derived); doesn't require Base to have a virtual
destructor.
我知道这个通过模板constructor实现
template
explicit shared_ptr(U* ptr);
但是关于怎么存储U,然后在把delete换成正确类型不太会。boost code不太看得懂
多谢!
p***o 发帖数: 1252
2
An object that knows the type U (Derived) is created on the heap.
The shared_ptr then accesses this object via runtime polymorphism
through its base class.
【在 t**i 的大作中提到】 : shared_ptr p(new Derived); doesn't require Base to have a virtual : destructor. : 我知道这个通过模板constructor实现 : template : explicit shared_ptr(U* ptr); : 但是关于怎么存储U,然后在把delete换成正确类型不太会。boost code不太看得懂 : 多谢!