Article View: gnu.gcc.help
Article #532(none)
From: Yann David
Date: Thu, 01 Oct 1992 11:25
Date: Thu, 01 Oct 1992 11:25
58 lines
1606 bytes
1606 bytes
From ydavid@dxds01.cern.ch Thu Oct 1 10:19:41 1992
Received: by dxmint.cern.ch (dxcern) (5.57/3.14)
id AA26973; Thu, 1 Oct 92 10:19:59 +0100
Received: by dxds01.cern.ch (5.57/Ultrix3.0-C)
id AA10785; Thu, 1 Oct 92 10:19:26 +0100
Date: Thu, 1 Oct 92 10:19:26 +0100
From: ydavid@dxds01.cern.ch (David Yann)
Message-Id: <9210010919.AA10785@dxds01.cern.ch>
To: ydavid@dxcern.cern.ch
Status: R
Hi there !
I am currently in the process of learning C++ and I have some difficulty
using static class variables (when compiling my .C files with gcc).
It seems that the linker does not recognize those static variables.
For example, the following program:
// Some difficulty using static class variables (& functions)
#include <stream.h>
class MyClass
{ static int a=0;
public:
void incA();
};
void MyClass::incA()
{ a+=1;
cout<<a;
}
main()
{ MyClass ex;
ex.incA();
ex.incA();
}
comes up with the following message:
ld:
Undefined:
_7MyClass$a
collect: /usr/bin/ld returned 1 exit status
which I don't understand.
Thank you in advance for your help!
Yann DAVID, student at CERN.
NB: I work on a DEC workstation, under ULTRIX.
Technical Details
Message-ID:
<9210010925.AA09167@dxcern.cern.ch>Path:
arc1-ca.pugleaf.net!sparky!uunet!think.com!wupost!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!dxcern.cern.ch!ydavidShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.help Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!wupost!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!dxcern.cern.ch!ydavid From: ydavid@dxcern.cern.ch (Yann David) Subject: (none) Message-ID: <9210010925.AA09167@dxcern.cern.ch> Sender: daemon@cis.ohio-state.edu Organization: GNUs Not Usenet Distribution: gnu Date: Thu, 1 Oct 1992 11:25:52 GMT Lines: 59