std::shared_ptr 与普通指针的转换

shared_ptr 是一个类,用模板支持很多类型。

1.shared_ptr到普通指针

shared_ptr<int>shared_a(10);

int *b=NULL;

b = &*shared_a;//*share_a 拷贝shared_a里面值创建临时对象, 再&取得临时对象地址

b = shared_a.get();

2.普通指针到shared_ptr

std::shared_ptr<CMyselfVideoWnd> myselfVideoWnd;

myselfVideoWnd.reset( new CMyselfVideoWnd());

在duilib 窗口delete在OnFinalMessage():

__super::OnFinalMessage(hWnd);
delete this;

--------------------- 本文来自 northeastsqure 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/northeastsqure/article/details/77962393?utm_source=copy

猜你喜欢

转载自blog.csdn.net/f110300641/article/details/82979701