Static constant class members

Vova vova-gs@yandex.ru
Sun Feb 29 16:49:00 GMT 2004


On Saturday 28 February 2004 22:13, Eljay Love-Jensen wrote:
> You cannot initialize static data members in-class.  (You can in Java, not
> in C++.)
This construction works fine in gcc 3.3

 class TxtVideo {
    protected:
      static const int test = 10;

>
> You need to do this:
>
> --- TxtVideo.h ---
> class TxtVideo {
>    protected:
> 	static unsigned int* const VBASE;
>
> --- TxtVideo.cpp ---
> unsigned int* const TxtVideo::VBASE = (unsigned int*) 0x0c00b8000L;
This is true, but actual value of the constant wouldn't be avaible in files 
which includes "TxtVideo.h", so compiler wouldn't insert it as imidiate 
operand, instead it will insert memory reference. Im I wrong ?

> HTH,
> --Eljahy



More information about the Gcc-help mailing list