Thread View: comp.std.c++
1 messages
1 total messages
Started by Alexandre Oliva
Tue, 27 Feb 1996 18:40
Re: Q: default constructor for fundamental types?
Author: Alexandre Oliva
Date: Tue, 27 Feb 1996 18:40
Date: Tue, 27 Feb 1996 18:40
29 lines
1645 bytes
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
]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads