struct SCtrl:Ctrl{ void Paint(Draw& w)override{ ... } }; Array<Ctrl> ctrls; Array<SCtrl> sctrls; ctrls.Create<Button>(); //this is ok sctrls.Create<Button>(); //this produces error(no matching member function for call to 'Add')
SCtrl& AddSplitter(int where,Ctrl *pfrom){ //SSplitterFrame& spl=splitters.Create<SSplitterFrame>(); //spl.FrameAdd(InsetFrame()); SCtrl& sc=ctrls.Create<SCtrl>(); sc.spl.Set(sc.SizePos(),100,where); if(!pfrom)pfrom=pwnd; sc.frmid=pfrom->GetFrameCount(); pfrom->AddFrame(sc.spl); return sc; } void NewPanel(int where,Ctrl *pfrom){ SCtrl&ctrl=AddSplitter(where,pfrom); //ctrl.ctrl.Create<Button>(); //Button&b=*(Button*)ctrl.ctrl.Get();b.SetLabel("Marana");b.LeftPos(20,100);b.TopPos(20,40); ////ctrl.ctrl->Add(b); }
1st question is more about c++, but anyway:
I have this struct.
struct SCtrl:Ctrl{ void Paint(Draw& w)override{ ... } }; Array<Ctrl> ctrls; Array<SCtrl> sctrls; ctrls.Create<Button>(); //this is ok sctrls.Create<Button>(); //this produces error(no matching member function for call to 'Add')
Can the last one be done, so that SCtrl is somehow subclassed but still used as Ctrl to be used as Button,...?
Any idea how to do this properly? maybe provide copyCtor?
1st question:
"Do what?"
I am subclassing Ctrl as SCtrl,
and i would like to use it - like it's written - in Array<SCtrl> sctrl;
sctrls.Create<Button>(); //this produces error(no matching member function for call to 'Add')