<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 379</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="379"></A><H4>379.
  
Change "class declaration" to "class definition"
</H4>
<B>Section: </B>Clause 11&#160; [<A href="https://wg21.link/class">class</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD1
 &#160;&#160;&#160;

 <B>Submitter: </B>Jens Maurer
 &#160;&#160;&#160;

 <B>Date: </B>21 Oct 2002<BR>


<P>[Voted into WP at March 2004 meeting.]</P>

<P>The ARM used the term "class declaration" to refer to what
would usually be termed the definition of the class.  The standard
now often uses "class definition", but there are some surviving uses
of "class declaration" with the old meaning.  They should be found
and changed.</P>

<P><B>Proposed resolution (April 2003):</B></P>

<P>
Replace in 6.2 [<A href="https://wg21.link/basic.def#2">basic.def</A>] paragraph 2</P>

<BLOCKQUOTE>
A declaration is a <I>definition</I> unless it declares a function
without specifying the function's body
(9.6 [<A href="https://wg21.link/dcl.fct.def">dcl.fct.def</A>]), it contains the
<TT>extern</TT> specifier (9.2.2 [<A href="https://wg21.link/dcl.stc">dcl.stc</A>]) or
a <I>linkage-specification</I>
[Footnote: Appearing inside the braced-enclosed
<I>declaration-seq</I> in a <I>linkage-specification</I> does not
affect whether a declaration is a definition.  --- end
footnote]
(9.12 [<A href="https://wg21.link/dcl.link">dcl.link</A>]) and neither an
<I>initializer</I> nor a <I>function-body</I>, it declares a static
data member in a class <DEL>declaration</DEL>
<INS>definition</INS>
(11.4.9 [<A href="https://wg21.link/class.static">class.static</A>]), it is a class name
declaration (11.3 [<A href="https://wg21.link/class.name">class.name</A>]), or it is
a <TT>typedef</TT> declaration
(9.2.4 [<A href="https://wg21.link/dcl.typedef">dcl.typedef</A>]), a
<I>using-declaration</I>
(9.10 [<A href="https://wg21.link/namespace.udecl">namespace.udecl</A>]), or a
<I>using-directive</I>
(9.9.4 [<A href="https://wg21.link/namespace.udir">namespace.udir</A>]).
</BLOCKQUOTE>

<P>
Replace in 9.2.3 [<A href="https://wg21.link/dcl.fct.spec">dcl.fct.spec</A>] paragraphs 5 and 6</P>

<BLOCKQUOTE>
<P>The <TT>virtual</TT> specifier shall only be used in declarations of
nonstatic class member functions that appear within a
<I>member-specification</I> of a class <DEL>declaration</DEL>
<INS>definition</INS>; see
11.7.3 [<A href="https://wg21.link/class.virtual">class.virtual</A>].</P>
<P>
The <TT>explicit</TT> specifier shall be used only in declarations of
constructors within a class <DEL>declaration</DEL>
<INS>definition</INS>; see
11.4.8.2 [<A href="https://wg21.link/class.conv.ctor">class.conv.ctor</A>].</P>
</BLOCKQUOTE>

<P>
Replace in 9.2.4 [<A href="https://wg21.link/dcl.typedef#4">dcl.typedef</A>] paragraph 4</P>

<BLOCKQUOTE>
A
<I>typedef-name</I>
that names a class is a
<I>class-name</I>
(11.3 [<A href="https://wg21.link/class.name">class.name</A>]).
If a <I>typedef-name</I> is used following the <I>class-key</I>
in an <I>elaborated-type-specifier</I>
(9.2.9.5 [<A href="https://wg21.link/dcl.type.elab">dcl.type.elab</A>]) or in the
<I>class-head</I>
of a class <DEL>declaration</DEL> <INS>definition</INS>
(Clause 11 [<A href="https://wg21.link/class">class</A>]),
or is used as the <I>identifier</I> in the declarator for a
constructor or destructor declaration
(11.4.5 [<A href="https://wg21.link/class.ctor">class.ctor</A>],
11.4.7 [<A href="https://wg21.link/class.dtor">class.dtor</A>]), the program is ill-formed.
</BLOCKQUOTE>

<P>
Replace in _N4868_.9.8.2.3 [<A href="https://wg21.link/namespace.memdef#3">namespace.memdef</A>] paragraph 3</P>

<BLOCKQUOTE>
The name of the friend is not found by simple name lookup until a
matching declaration is provided in that namespace scope (either
before or after the class <DEL>declaration</DEL>
<INS>definition</INS> granting friendship).
</BLOCKQUOTE>

<P>
Replace in 9.3.4.3 [<A href="https://wg21.link/dcl.ref#4">dcl.ref</A>] paragraph 4</P>

<BLOCKQUOTE>
There shall be no references to references, no arrays of references,
and no pointers to references.  The declaration of a reference shall
contain an <I>initializer</I>
(9.5.4 [<A href="https://wg21.link/dcl.init.ref">dcl.init.ref</A>]) except when
the declaration contains an explicit <TT>extern</TT> specifier
(9.2.2 [<A href="https://wg21.link/dcl.stc">dcl.stc</A>]), is a class member
(11.4 [<A href="https://wg21.link/class.mem">class.mem</A>]) declaration within a
class <DEL>declaration</DEL> <INS>definition</INS>, or is the
declaration of a parameter or a return type
(9.3.4.6 [<A href="https://wg21.link/dcl.fct">dcl.fct</A>]); see
6.2 [<A href="https://wg21.link/basic.def">basic.def</A>].
</BLOCKQUOTE>

<P>
Replace in 9.5.4 [<A href="https://wg21.link/dcl.init.ref#3">dcl.init.ref</A>] paragraph 3</P>
<BLOCKQUOTE>
The initializer can be omitted for a reference only in a parameter
declaration (9.3.4.6 [<A href="https://wg21.link/dcl.fct">dcl.fct</A>]), in the
declaration of a function return type, in the declaration of a class
member within its class <DEL>declaration</DEL> <INS>definition</INS>
(11.4 [<A href="https://wg21.link/class.mem">class.mem</A>]), and where the
<TT>extern</TT> specifier is explicitly used.
</BLOCKQUOTE>

<P>
Replace in 11.3 [<A href="https://wg21.link/class.name#2">class.name</A>] paragraph 2</P>
<BLOCKQUOTE>
A class <DEL>definition</DEL> <INS>declaration</INS> introduces the
class name into the scope where it is <DEL>defined</DEL>
<INS>declared</INS> and hides any class, object, function, or other
declaration of that name in an enclosing scope
(6.4 [<A href="https://wg21.link/basic.scope">basic.scope</A>]).  If a class name
is declared in a scope where an object, function, or enumerator of the
same name is also declared, then when both declarations are in scope,
the class can be referred to only using an
<I>elaborated-type-specifier</I>
(6.5.6 [<A href="https://wg21.link/basic.lookup.elab">basic.lookup.elab</A>]).
</BLOCKQUOTE>

<P>
Replace in 11.4.9 [<A href="https://wg21.link/class.static#4">class.static</A>] paragraph 4</P>
<BLOCKQUOTE>
Static members obey the usual class member access rules (
11.8 [<A href="https://wg21.link/class.access">class.access</A>]).  When used
in the declaration of a class member, the <TT>static</TT> specifier
shall only be used in the member declarations that appear within the
<I>member-specification</I> of the class <DEL>declaration</DEL>
<INS>definition</INS>.
</BLOCKQUOTE>

<P>Replace in 11.4.12 [<A href="https://wg21.link/class.nest#1">class.nest</A>] paragraph 1</P>
<BLOCKQUOTE>
A class can be <DEL>defined</DEL> <INS>declared</INS> within another
class.  A class <DEL>defined</DEL> <INS>declared</INS> within
another is called a <I>nested</I> class.  The name of a nested class
is local to its enclosing class.  The nested class is in the scope of
its enclosing class.  Except by using explicit pointers, references,
and object names, declarations in a nested class can use only type
names, static members, and enumerators from the enclosing class.
</BLOCKQUOTE>

<P>
Replace in 11.6 [<A href="https://wg21.link/class.local#1">class.local</A>] paragraph 1</P>
<BLOCKQUOTE>
A class can be <DEL>defined</DEL> <INS>declared</INS> within a
function definition; such a class is called a <I>local</I> class.  The
name of a local class is local to its enclosing scope.  The local
class is in the scope of the enclosing scope, and has the same access
to names outside the function as does the enclosing function.
Declarations in a local class can use only type names, static
variables, <TT>extern</TT> variables and functions, and enumerators
from the enclosing scope.
</BLOCKQUOTE>

<P>
Replace in 11.7 [<A href="https://wg21.link/class.derived#1">class.derived</A>] paragraph 1</P>
<BLOCKQUOTE>
... The <I>class-name</I> in a <I>base-specifier</I> shall not be an
incompletely defined class (Clause 11 [<A href="https://wg21.link/class">class</A>]);
this class is called a
<I>direct</I> <I>base</I> <I>class</I> for the class being
<DEL>declared</DEL> <INS>defined</INS>.  During the lookup for a
base class name, non-type names are ignored
(_N4868_.6.4.10 [<A href="https://wg21.link/basic.scope.hiding">basic.scope.hiding</A>]).
If the name found is not a <I>class-name</I>, the program is ill-formed.
A class <TT>B</TT> is a base class of a class <TT>D</TT> if it is a
direct base class of <TT>D</TT> or a direct base class of one of
<TT>D</TT>'s base classes.  A class is an <I>indirect</I> base class
of another if it is a base class but not a direct base class.  A class
is said to be (directly or indirectly) <I>derived</I> from its (direct
or indirect) base classes.  [<I>Note:</I> See
11.8 [<A href="https://wg21.link/class.access">class.access</A>]
for the meaning of <I>access-specifier</I>.]  Unless
<DEL>redefined</DEL> <INS>redeclared</INS> in the
derived class, members of a base class are also considered to be
members of the derived class.  The base class members are said to be
<I>inherited</I> by the derived class.  Inherited members can be
referred to in expressions in the same manner as other members of the
derived class, unless their names are hidden or ambiguous
(6.5.2 [<A href="https://wg21.link/class.member.lookup">class.member.lookup</A>]).
[<I>Note:</I> the scope resolution operator <TT>::</TT>
(_N4567_.5.1.1 [<A href="https://wg21.link/expr.prim.general">expr.prim.general</A>])
can be used to refer to a direct or indirect base member explicitly.
This allows access to a name that has been <DEL>redefined</DEL>
<INS>redeclared</INS> in the derived class.  A derived class can itself
serve as a base class subject to access control; see
11.8.3 [<A href="https://wg21.link/class.access.base">class.access.base</A>].
A pointer to a derived class can be implicitly converted to a pointer
to an accessible unambiguous base class
(7.3.12 [<A href="https://wg21.link/conv.ptr">conv.ptr</A>]).
An lvalue of a derived class type can be bound to a reference to an
accessible unambiguous base class
(9.5.4 [<A href="https://wg21.link/dcl.init.ref">dcl.init.ref</A>]).]
</BLOCKQUOTE>

<P>
Replace in 11.7.2 [<A href="https://wg21.link/class.mi#5">class.mi</A>] paragraph 5</P>
<BLOCKQUOTE>
For another example,
<BLOCKQUOTE><TT><PRE>
class V { /* ... */ };
class A : virtual public V { /* ... */ };
class B : virtual public V { /* ... */ };
class C : public A, public B { /* ... */ };
</PRE></TT></BLOCKQUOTE>
for an object <TT>c</TT> of class type <TT>C</TT>, a single subobject
of type <TT>V</TT> is shared by every base subobject of <TT>c</TT>
that <DEL>is declared to have</DEL> <INS>has</INS> a
<TT>virtual</TT> base class of type <TT>V</TT>.
</BLOCKQUOTE>

<P>
Replace in the example in 6.5.2 [<A href="https://wg21.link/class.member.lookup#6">class.member.lookup</A>] paragraph 6
(the whole paragraph was turned into a note by the
resolution of <A HREF="39.html">core issue 39</A>)</P>
<BLOCKQUOTE>
The names <DEL>defined</DEL> <INS>declared</INS> in <TT>V</TT> and
the left hand instance of <TT>W</TT> are hidden by those in
<TT>B</TT>, but the names <DEL>defined</DEL> <INS>declared</INS> in
the right hand instance of <TT>W</TT> are not hidden at all.
</BLOCKQUOTE>

<P>
Replace in 11.7.4 [<A href="https://wg21.link/class.abstract#2">class.abstract</A>] paragraph 2</P>
<BLOCKQUOTE>
... A virtual function is specified <I>pure</I> by using a
<I>pure-specifier</I> (11.4 [<A href="https://wg21.link/class.mem">class.mem</A>])
in the function declaration in the class <DEL>declaration</DEL>
<INS>definition</INS>. ...
</BLOCKQUOTE>

<P>
Replace in the footnote at the end of 11.8.3 [<A href="https://wg21.link/class.access.base#1">class.access.base</A>] paragraph 1
</P>
<BLOCKQUOTE>
[Footnote: As specified previously in
11.8 [<A href="https://wg21.link/class.access">class.access</A>], private members of
a base class remain inaccessible even to derived classes unless
<TT>friend</TT> declarations within the base class
<DEL>declaration</DEL> <INS>definition</INS> are used to grant access
explicitly.]
</BLOCKQUOTE>

<P>
Replace in _N3225_.11.3 [<A href="https://wg21.link/class.access.dcl#1">class.access.dcl</A>] paragraph 1</P>
<BLOCKQUOTE>
The access of a member of a base class can be changed in the derived
class by mentioning its <I>qualified-id</I> in the derived class
<DEL>declaration</DEL> <INS>definition</INS>.  Such mention is
called an <I>access</I> <I>declaration</I>. ...
</BLOCKQUOTE>

<P>
Replace in the example in 12.3 [<A href="https://wg21.link/over.over#5">over.over</A>] paragraph 5</P>
<BLOCKQUOTE>
The initialization of <TT>pfe</TT> is ill-formed because no
<TT>f()</TT> with type <TT>int(...)</TT> has been
<DEL>defined</DEL> <INS>declared</INS>, and not because of any
ambiguity.
</BLOCKQUOTE>

<P>
Replace in C.7.6 [<A href="https://wg21.link/diff.dcl#1">diff.dcl</A>] paragraph 1</P>
<BLOCKQUOTE>
<INS>Rationale:</INS> Storage class specifiers don't have any meaning when
associated with a type.  In C++, class members can be
<DEL>defined</DEL> <INS>declared</INS> with the <TT>static</TT>
storage class specifier.  Allowing storage class specifiers on type
declarations could render the code confusing for users.
</BLOCKQUOTE>

<P>
Replace in C.7.7 [<A href="https://wg21.link/diff.class#3">diff.class</A>] paragraph 3</P>
<BLOCKQUOTE>
In C++, a typedef name may not be <DEL>redefined</DEL> <INS>redeclared</INS> in a class
<DEL>declaration</DEL> <INS>definition</INS> after being used in <DEL>the
declaration</DEL> <INS>that definition</INS>
</BLOCKQUOTE>

<I>Drafting notes:</I>
<P>
The resolution of <A HREF="45.html">core issue 45</A> (DR)
deletes 11.8.8 [<A href="https://wg21.link/class.access.nest#2">class.access.nest</A>] paragraph 2.</P>

<P>
The following occurrences of "class declaration" are not changed:</P>
<UL>
<LI>7.6.2.8 [<A href="https://wg21.link/expr.new#4">expr.new</A>] paragraph 4
</LI>

<LI>9.2.4 [<A href="https://wg21.link/dcl.typedef#1">dcl.typedef</A>] paragraph 1
</LI>

<LI>11.3 [<A href="https://wg21.link/class.name">class.name</A>] paragraphs 3 and 4
</LI>

<LI>11.8.4 [<A href="https://wg21.link/class.friend#9">class.friend</A>] paragraph 9
</LI>

<LI>C.7.7 [<A href="https://wg21.link/diff.class#1">diff.class</A>] paragraph 1
</LI>

</UL>

<BR><BR>
</BODY>
</HTML>
