mirror of
https://github.com/CnTransGroup/EffectiveModernCppChinese.git
synced 2024-12-28 05:40:43 +08:00
commit
deb428addf
@ -31,14 +31,14 @@
|
||||
|
||||
```cpp
|
||||
class Investment { ... };
|
||||
class Sock: public Investment {...};
|
||||
class Stock: public Investment {...};
|
||||
class Bond: public Investment {...};
|
||||
class RealEstate: public Investment {...};
|
||||
```
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
Investment <|-- Sock
|
||||
Investment <|-- Stock
|
||||
Investment <|-- Bond
|
||||
Investment <|-- RealEstate
|
||||
```
|
||||
@ -121,7 +121,7 @@ makeInvestment(Ts&& params)
|
||||
|
||||
```cpp
|
||||
template<typename... Ts>
|
||||
makeInvestment(Ts&& params)
|
||||
auto makeInvestment(Ts&& params)
|
||||
{
|
||||
auto delInvmt = [](Investment* pInvestment)
|
||||
{
|
||||
@ -187,4 +187,4 @@ std::shared_ptr<Investment> sp = makeInvestment(arguments);
|
||||
|
||||
- `std::unique_ptr`是轻量级、快速的、只能move的管理专有所有权语义资源的智能指针
|
||||
- 默认情况,资源销毁通过delete,但是支持自定义delete函数。有状态的删除器和函数指针会增加`std::unique_ptr`的大小
|
||||
- 将`std::unique_ptr`转化为`std::shared_ptr`是简单的
|
||||
- 将`std::unique_ptr`转化为`std::shared_ptr`是简单的
|
||||
|
Loading…
Reference in New Issue
Block a user