This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
static memeber initialization in constructor??
- From: Ishwar Rattan <ishwar at pali dot cps dot cmich dot edu>
- To: gcc-help at gcc dot gnu dot org
- Date: Mon, 1 Nov 2004 15:24:34 -0500 (EST)
- Subject: static memeber initialization in constructor??
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?
-ishwar