Re: Default constructor

From: jeffc (nobody_at_nowhere.com)
Date: 09/02/04


Date: Thu, 2 Sep 2004 12:34:59 -0400


"Cy Edmunds" <cedmunds@spamless.rochester.rr.com> wrote in message
news:sTpYc.207327$bp1.7462@twister.nyroc.rr.com...
>
> 2) Automatic default constructor inserted even if the programmer provides
a
> constructor with arguments. Now the client can declare objects of this
type
> without providing the arguments, possibly leaving the object in an
undefined
> state again. The programmer can define a private default constructor but
> that seems like too much trouble for what is after all a perfectly common
> situation.
>
> In short, there seems to be no reasonable alternative.

2 is a reasonable alternative, they just chose not to do it that way. (If
the programmer thought creating an object with no initializing parameters
were bad, he could simply define a default constructor that initialized
things in a default way.) Philosophically, they just decided that when the
programmer takes over, he takes over all. No technical reason it has to be
that way.



Relevant Pages

  • Re: constructor
    ... void foo() ... you didn't call a constructor from main. ... Yes, of course it can be called, but not by the programmer. ... that you're explaining incorrect things to novice programmers? ...
    (comp.lang.cpp)
  • Re: Overflow or underflow in the arithmetic operation when showing form AGAIN?
    ... When are you calling FixFPU? ... between the start of the constructor and when the font is created. ... I contacted the programmer and he told me "XXX ... > Support AT NOSPAM Zerama DOT NET ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: What is the best way to set options in a constructor
    ... > Well, if you want to obscure your code, go ahead. ... > constructor out of habit. ... but I also consider myself an advanced average Perl programmer ... my $dbi = new DBI; ...
    (perl.beginners)
  • Re: base/derived name unhiding but with ctors
    ... If e.g. it is a pointer to a function ... pointer to a constructor, because you cannot call a constructor, ... and that can't be explicitly done by the programmer. ... destructor calls", because a destructor can't be called, just like a ...
    (comp.lang.cpp)