static memeber initialization in constructor??
Paweł Sikora
pluto@pld-linux.org
Mon Nov 1 20:33:00 GMT 2004
On Monday 01 of November 2004 21:24, Ishwar Rattan wrote:
> g++ 3.2.2 under Linux Mandrake-9.1
>
> I have a class A being derived from base class B
>
> class A: public B
> {
> public:
>
> A() : B("starter") { init_one(); }
>
> // other public methods..
>
> protected:
> const int MAX = 10;
> static long one[MAX];
> static void init_one()
> {
> for(int i = 0; i < MAX; i++)
> one[i] = 9;
> }
> };
>
>
> Whem compiled the ld fails with message that there is undefined reference
> to A::one
>
> So, can one initialize a static member in the above scenario?
You need minor fix.
--
/* Copyright (C) 2003, SCO, Inc. This is valuable Intellectual Property. */
#define say(x) lie(x)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0.diff
Type: text/x-diff
Size: 362 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20041101/ea4428ee/attachment-0001.bin>
More information about the Gcc-help
mailing list