|
From: | jk |
Subject: | Re: undefined error message for static variable during link phase |
Date: | Tue, 01 Feb 2005 00:29:33 +0100 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040616 |
thanks all: I fixed it -- newbies seem to have strange "blindness" effects ;)struct Foo { static int x; }; int main() { Foo f; return f.x; }the static variable foo1 is being declared undefined during link phase.That's correct: you provided a declaration, but no definition for it. Fix: struct Foo { static int x; }; int Foo::x = 0; // storage for 'Foo::x' is reserved here (and only here) int main() { Foo f; return f.x; }
Jörg -- ================= lat=52.35°N - lon=10.25°E ====================== http://www.ibk-consult.de
[Prev in Thread] | Current Thread | [Next in Thread] |