Article View: comp.std.c++
Article #1685Re: point of defn and default and default arguments
From: James Kanze US/ESC 60/3/141 #407...
Date: Wed, 09 Aug 1995 08:48
Date: Wed, 09 Aug 1995 08:48
56 lines
2188 bytes
2188 bytes
In article <DCxJ3u.A96@online.tmx.com.au> tony@online.tmx.com.au (Tony
Cook) writes:
|> Is the following legal:
It's legal.
|> class T
|> {
|> public:
|> T() {}
|> //
|> T(int,
|> T const &def_ = T() // note this - use before end of class
|> ) { }
|> };
|> int main()
|> {
|> T t(0);
|> return 0;
|> }
|> Why it might be legal:
|> default arguments are evaluated at the point of use.
|> [dcl.fct.default]
|> 9 Default arguments are evaluated at each point of call before entry
|> into a function.
Correct.
|> Why it might not be legal:
|> names for default arguments are bound at point of declaration,
|> and T is not fully defined where the default argument is declared.
|> [dcl.fct.default]
|> 5 Default argument expressions have their names bound and their types
|> checked at the point of declaration.
|> [class] p2
|> A
|> class is considered defined after the closing brace of its class-
|> specifier has been seen even though its member functions are in gen-
|> eral not yet defined.
Binding a name does not require a complete type. In fact,
technically, it doesn't require any semantic information concerning
the name. (In practice, there is no way for you to make a name known
to the compiler without providing some semantic information.)
--
James Kanze Tel.: (+33) 88 14 49 00 email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
Conseils en informatique industrielle --
-- Beratung in industrieller Datenverarbeitung
Technical Details
Message-ID:
<KANZE.95Aug9104803@slsvhdt.lts.sel.alcatel.de>Path:
arc1-ca.pugleaf.net!xlink.net!slsv6bt!newsReferences:
<DCxJ3u.A96@online.tmx.com.au>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++ Path: arc1-ca.pugleaf.net!xlink.net!slsv6bt!news From: kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763) Subject: Re: point of defn and default and default arguments In-Reply-To: tony@online.tmx.com.au's message of Mon, 7 Aug 1995 07:21:30 GMT Message-ID: <KANZE.95Aug9104803@slsvhdt.lts.sel.alcatel.de> Sender: news@lts.sel.alcatel.de Organization: SEL References: <DCxJ3u.A96@online.tmx.com.au> Date: 09 Aug 1995 08:48:03 GMT