c++ - shared_ptr or unique_ptr to CustomDialogEx -
hell all,
i creating tab-controls on fly. purpose, doing
customdialogex *tabpages[total_modules];
and in constructor doing
cmoduletabctrl::cmoduletabctrl() { tabpages[0] = new cpodule; tabpages[1] = new csbmodule; tabpages[2] = new cptmodule; tabpages[3] = new cqsmodule; }
and in init() method, doing
void cmoduletabctrl::init() { // add dialog pages 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); }
when tried use smart pointers this
std::unique_ptr<customdialogex[total_modules]>tabpages;
it giving error @ place calling base class member functions. example:
tabpages[0]->create(idd_dlg_p, this);
it gives following error...
left of '->create' must point class/struct/union/generic type
how implement using smart pointers?
thanks.
you're creating pointer array of base-class objects, isn't want. want array of pointers, in first example:
std::unique_ptr<customdialogex> tabpages[total_modules]; tabpages[0].reset(new cpodule); // create first object tabpages[0]->create(idd_dlg_p, this); // weird second-stage initialisation
Comments
Post a Comment