Mailinglist Archive: opensuse-programming (98 mails)

< Previous Next >
Re: [suse-programming-e] C++:Can one constructor call another from the same object?
  • From: Davi de Castro Reis <davicastro@xxxxxxxxxxxx>
  • Date: Mon, 01 Mar 2004 05:46:49 -0300
  • Message-id: <4042F879.2020902@xxxxxxxxxxxx>
Jerry Feldman wrote:

On Fri, 27 Feb 2004 06:55:29 -0500
"Steven T. Hatton" <hattons@xxxxxxxxxxxxxxxxxx> wrote:

>In Java it's quite common to call one constructor from another one in
>the same objects. Can that be done in C++? Is the same kind of
>situation handled in C++ with default values for arguments to the
>constructor rather than having two different constructors?

Yes. In general the base class constructor is called implicitly, but you

I think Steven asked if the constructor of the _own_ object can be called inside another constructor.
I don't think it is possible. You usually mimic it with defaults values, but I really prefer the Java approach (actually, it is probably the only thing I like in Java).

[]s
Davi

< Previous Next >
Follow Ups