User Profile

Collapse

Profile Sidebar

Collapse
morphique
morphique
Last Activity: Mar 3 '10, 11:52 PM
Joined: Feb 28 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • morphique
    replied to template inheritance
    in C
    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.
    See more | Go to post

    Leave a comment:


  • morphique
    replied to template inheritance
    in C
    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>
    See more | Go to post

    Leave a comment:


  • morphique
    replied to template inheritance
    in C
    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++)
    ...
    See more | Go to post

    Leave a comment:


  • morphique
    replied to template inheritance
    in C
    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.
    See more | Go to post

    Leave a comment:


  • morphique
    started a topic template inheritance
    in C

    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
    ...
    See more | Go to post
    Last edited by Banfa; Mar 1 '10, 09:29 AM. Reason: Added code tags
No activity results to display
Show More
Working...