Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #36689

Re: "default constructor"

From Juha Nieminen <nospam@thanks.invalid>
Newsgroups comp.lang.java.programmer, comp.lang.c++
Subject Re: "default constructor"
Date 2017-06-21 14:32 +0000
Organization Netfront http://www.netfront.net/
Message-ID <oie01p$1gr1$1@adenine.netfront.net> (permalink)
References <default-constructor-20170619023834@ram.dialup.fu-berlin.de>

Cross-posted to 2 groups.

Show all headers | View raw


In comp.lang.c++ Stefan Ram <ram@zedat.fu-berlin.de> wrote:
>   In C++, it is a constructor that can be called with missing
>   arguments (no arguments).

I have the impression that the word "default" is used in a somewhat
different meaning here.

Rather than meaning the same as "implicit constructor" (which is what
you are referring to), it means "the constructor that's called by
default when there is no explicit constructor call in the code
that instantiates the class" (or, in other words, when the class
is instantiated without any parameters).

In other words, when you write:

  MyClass obj;

the default constructor is called because no other constructor
call was specified explicitly. It doesn't matter whether that
default constructor was implicitly created by the compiler, or
explicitly declared in the implementation of the class.

Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: "default constructor" Juha Nieminen <nospam@thanks.invalid> - 2017-06-21 14:32 +0000
  Re: "default constructor" "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2017-06-21 18:07 +0200
    Re: "default constructor" Eric Douglas <e.d.programmer@gmail.com> - 2017-06-21 10:26 -0700

csiph-web