Topic: Private typedef for static member
Author: Valentin Bonnard <bonnardv@pratique.fr>
Date: 1997/10/12 Raw View
[cross-posted to comp.std.c++, followup set there]
Frank Patz <fp@contact.de> writes:
> Consider:
>
> class C {
> private:
> typedef something T;
> static T member;
> };
>
> According to Stroustrup and ARM, declaring `member' is
> not enough, it also has to be *defined* somewhere, like:
>
> C::T C::member;
>
> This compiles without warnings with some compilers (GCC),
> but others (SGI C++) emit a warning, saying that using C::T
> "outside" the scope of C is not allowed.
>
> I wonder wether the definition statement is inside or outside
> the scope of class C? Any comments?
1) this correct definition is written at namespace/global
scope, but there are no problems
2) these definitions are useless and should IMO disappear
as the provide no additionnal information wrt the
declaration.
The same for:
struct T {
static const int i = 4;
static const float f = 3.14; // should be allowed
};
const int T::i; // stupid useless definition
const float T::f = 3.14; // again, no need for it
--
Valentin Bonnard mailto:bonnardv@pratique.fr
info about C++/a propos du C++: http://www.pratique.fr/~bonnardv/
[ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
[ about comp.lang.c++.moderated. First time posters: do this! ]
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]