Re: trying to call a virtual method from constructor of abstract object

From: as mellow as a horse (mail_at_MICKmoss42.fslife.co.uk)
Date: 06/14/04


Date: Sun, 13 Jun 2004 23:02:46 +0100


"T.M. Sommers" <tms@nj.net> wrote in message
news:u8adnV-hM-6kP1HdUSdV9g@telcove.net...
> as mellow as a horse wrote:
> >
> > I guess it's obvious that the constructor of CObject can't see the
derived
> > classes definition of init(), but I want any derived object to call
init()
> > automatically, and removing the init() call from the constructor and
adding
> > it to derived concrete classes is not really a solution.
>
> Can you explain why you cannot wait to initialize the
> derived-class object until it exists? I am baffled.

I don't want to do that at all. I just need to ensure that init() is called
(and called first) before anything else. If I can't do that, I'll have to
remove init() altogether and have the user of any derived objects put
anything they would have put inside init inside the derived constructor.

> Thomas M. Sommers -- tms@nj.net -- AB2SB
>



Relevant Pages

  • Re: Convenience constructors and non-final setters
    ... comfort severely (ok, I guess that argument doesn't count for OO-purists), ... init() method which would have been called before setSeed. ... constructor runs, initruns, setSeedruns, and the subclass ... In my opinion they should have made Random abstract, ...
    (comp.lang.java.programmer)
  • Re: All those constructors...
    ... > I have this fairly large class heirarchy, ... creating package visible setXXX() for the init parameters ... creating a public init() method which subclasses use for their constructor ...
    (comp.lang.java.programmer)
  • Re: is such exception handling approach good?
    ... an oracle database in the ctor then what should you do ... of them in constructor; sometimes all of them. ... void AllInOne::RetrieveData ... assert("Cannot init the buffer twice!"); ...
    (microsoft.public.vc.language)
  • Re: is such exception handling approach good?
    ... "Alex Blekhman" wrote: ... of them in constructor; sometimes all of them. ... void AllInOne::RetrieveData ... assert("Cannot init the buffer twice!"); ...
    (microsoft.public.vc.language)
  • Re: Remoting service wont start
    ... I often see those kinds of errors in services because of things like syntax errors in the App.config file, or in the constructor, or on init. ... Does anyone know what might be causing it? ...
    (microsoft.public.dotnet.general)