🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

point of defn and default and default arguments

#1665
From: Tony Cook
Date: Mon, 07 Aug 1995 07:21
42 lines
1366 bytes
Is the following 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.

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.
-- 
        Tony Cook - tony@online.tmx.com.au
                    100237.3425@compuserve.com
Technical Details
Message-ID: <DCxJ3u.A96@online.tmx.com.au>
Path: arc1-ca.pugleaf.net!news.tmx.com.au!tony

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++
Path: arc1-ca.pugleaf.net!news.tmx.com.au!tony
From: tony@online.tmx.com.au (Tony Cook)
Subject: point of defn and default and default arguments
Message-ID: <DCxJ3u.A96@online.tmx.com.au>
Organization: Home
Date: Mon, 7 Aug 1995 07:21:30 GMT
X-Newsreader: TIN [version 1.2 PL2]