Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 31,390 of 33,346    |
|    cpp4ever to asif.lse    |
|    Re: Way to generate member in derived cl    |
|    12 Aug 11 02:27:28    |
      64ce1edd       From: n2xssvv.g02gfr12930@ntlworld.com              On 11/08/11 09:59, asif.lse wrote:       > Hi,       >       > I have a class with a member template function - in my derived class       > constructor, I instantiate multiple instances of this template - those       > instances get instantiated in the Base class though. Is there any way       > you could suggest that I could use to generate instances in the       > derived class? I am not sure but I suspect there *can* be a way to       > accomplish this - just like CRTP where we generate members in Base       > class with Derived class information. Though there is no problem in       > functionality but putting generated members in the base class is       > semantically wrong - the correct place for those generated members is       > the derived class.       >       > Thanks in advance, Asif       >       >              An example would make things clearer. If the base class uses a member       function for instantiation, then why not make that virtual and over ride       it in the derived classes? This does sound like a factory pattern       problem, so a factory class might be necessary.              regards              cpp4ever                     --        [ See http://www.gotw.ca/resources/clcm.htm for info about ]        [ comp.lang.c++.moderated. First time posters: Do this! ]              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca