yes that's what causing issues. is there any way I can execute ST virtual functions on BP<DD> which i doubt. any design pattern recommend which best fits this scenario. I am willing to make design changes unless they are drastic.
Thanks for you time I really appreciate that.
User Profile
Collapse
-
DD is derived class and ST is base class. that all works fine. The issue is with BP which derives from template class argument.
So instead of creating
BP1 from DD1
BP2 from DD2
BP3 from DD3
i have created
template<class T>
BP : public <T>
DD1, DD2, DD3 and so on all derives from ST
so I just want to cast BP<DD1>, BP<DD2> so on to BP<ST>Leave a comment:
-
Code:if ((*pmapVarNameAndValues)["type"] == "stddeviation") { shared_ptr<BP<StdDeviations> > pBP(new BP<StdDeviations>()); SHlpr::ConfigureStdDeviationsFromVariables(boost::dynamic_pointer_cast<StdDeviations>(pBP), *pmapVarNameAndValues); pBP->m_itStartTime = iStartTimeOffset; for(int i = 0; i < iRows - 1; i++)
Leave a comment:
-
it's not casting from DD to ST which is a problem as that works. ST contains virtual methods. It's a casting from BP<DD> to BP<ST> which throws runtime exception.Leave a comment:
-
template inheritance
how can I get this upcasting to work:
Code:template <class T> class BP : public T {} ; class DD : public class ST {} ; class ST {}; int main(int argc, char** argv) { shared_ptr<BP<ST> > spST; shared_ptr<BP<DD> > spDD(new BP<DD>()); spST = boost::dynamic_pointer_cast<BP<ST> >(spDD); <-----------this
No activity results to display
Show More
Leave a comment: