🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3523

Re: Q: default constructor for fundamental types?

#3523
From: Alexandre Oliva
Date: Tue, 27 Feb 1996 18:40
29 lines
1645 bytes
Dirk Herrmann writes:

> Sorry if this has been discussed before.
> When using templates, it appears that there should be
> default constructors for the fundamental data types.

You  need  not invoke  default    constructors explicitly.  By  simply
removing ": t()" from the following code snippet, it will compile fine
even for X<int>.  For types which  have a default constructor, it will
be invoked, as it should.

template <class T>
class X {
private:
  T t;
public:
  X() /* : t() */ {}
};
-- 
Alexandre Oliva
oliva@dcc.unicamp.br
Universidade Estadual de Campinas, S~ao Paulo, Brasil
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu 
]
Technical Details
Message-ID: <orn365ieob.fsf@grande.dcc.unicamp.br>
Path: arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austern

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austern
From: oliva@grande.dcc.unicamp.br (Alexandre Oliva)
Newsgroups: comp.std.c++
Subject: Re: Q: default constructor for fundamental types?
Date: 27 Feb 1996 10:40:34 PST
Organization: DCC - UNICAMP - Campinas, SP, Brazil
Approved: austern@isolde.mti.sgi.com
Message-ID: <orn365ieob.fsf@grande.dcc.unicamp.br>
NNTP-Posting-Host: isolde.mti.sgi.com
X-Original-Date: 27 Feb 1996 01:19:00 -0300
X-Newsreader: Gnus v5.1
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBVAwUBMTNQNUy4NqrwXLNJAQE5RgIArZcJcGK0s9K+IQwATK1K2gFF0TzLWI+r
 EyfB2VCpNLu85CqldSHFckcuBkpWKauvGcdu5G0i1iGkCoVUIz6TRg==
 =dEeg
Originator: austern@isolde.mti.sgi.com