James Kanze
9/29/2008 8:24:00 AM
On Sep 29, 4:40 am, Jeffrey <jkar...@gmail.com> wrote:
> My understanding is that if you write
> class X {
> int y;
> static int z;
> };
> then you've defined (and declared) X and y, but you have only
> declared (and not defined) z. If you'd like to actually
> define z, you also need to add
> int X::z;
> Can anybody tell me the reason that the language was designed
> to be like this? It seems it would be simpler if z were
> defined in the same way as y, so presumably there's some good
> reason.
Mainly historical reasons, I suspect, but of course, if there is
an initializer (as there usually should be), you usually don't
want it in a header.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34