Article View: gnu.g++.bug
Article #217Re: simpler example of previous g++ bug report - unresolved static member
From: Gnanasekaran Swaminathan
Date: Wed, 29 Jul 1992 22:45
Date: Wed, 29 Jul 1992 22:45
28 lines
1132 bytes
1132 bytes
eric@cathaus.utcs.utoronto.ca (Eric M. Carroll) wonders why he his getting
undefined symbol errors for static member variables in his
programs.
You need a definition for your static variables somewhere in your
program. The static variables must be defined in the file scope and
only once in your program.
|class A {
| public:
| void test() ;
|
| private:
| static int value ;
|} ;
|
|void A::test() {
| value = 0 ;
|}
int A::value = 10; // definition for the static variable A::value
|main() {
|
| return 0 ;
|}
-Sekar
Technical Details
Message-ID:
<1992Jul29.224514.4893@murdoch.acc.Virginia.EDU>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!virginia.edu!gs4tReferences:
<9207291707.AA04988@cathaus.utcs.utoronto.ca>Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!virginia.edu!gs4t From: gs4t@virginia.edu (Gnanasekaran Swaminathan) Subject: Re: simpler example of previous g++ bug report - unresolved static member Message-ID: <1992Jul29.224514.4893@murdoch.acc.Virginia.EDU> Sender: gnulists@ai.mit.edu Reply-To: gs4t@virginia.edu (Gnanasekaran Swaminathan) Organization: University of Virginia References: <9207291707.AA04988@cathaus.utcs.utoronto.ca> Distribution: gnu Date: Wed, 29 Jul 1992 22:45:14 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 29