bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Static class member initialization buggy?


From: Johnny Wezel
Subject: Static class member initialization buggy?
Date: 11 Dec 2001 07:26:11 -0800

I tried to introduce a type ID into several classes by a construct
like this:

x.h:
====
class X {
  ...
  static short type;
}

x.cc:
=====

short X::type = nextType++;
But all classes got the same type value: the last one (ie. for, say 5
classes, all got type=5). I tried different implementations: assigning
through a function which has a static variable inside, const,
non-const, it's always the same.

Is this:

a) a bug in GNU C++
b) not allowed to be used this way

System info:
============

OS: Linux 2.4.4
Compiler: g++ 2.95.3
Cheers
Johnny Wezel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]