地獄所有,shared_ptr或unique_ptr到CustomDialogEx
我在飛行中創建標籤控件。爲此,我在做什麼
CustomDialogEx *tabPages[TOTAL_MODULES];
,並在構造函數中我做
CModuleTabCtrl::CModuleTabCtrl()
{
tabPages[0] = new CPodule;
tabPages[1] = new CSBModule;
tabPages[2] = new CPTModule;
tabPages[3] = new CQSModule;
}
,並在init()方法,我在做什麼
void CModuleTabCtrl::Init()
{
// Add Dialog pages to tabPages array.
tabPages[0]->Create(IDD_DLG_P, this);
tabPages[1]->Create(IDD_DLG_SB, this);
tabPages[2]->Create(IDD_DLG_PT, this);
tabPages[3]->Create(IDD_DLG_QS, this);
}
當我試圖用像這樣的智能指針
std::unique_ptr<CustomDialogEx[TOTAL_MODULES]>tabPages;
它在我調用基類成員函數的地方給出錯誤。 例子:
tabPages[0]->Create(IDD_DLG_P, this);
它提供了以下錯誤......
left of '->Create' must point to class/struct/union/generic type
如何實現用智能指針?
謝謝。