delorie.com/archives/browse.cgi | search |
From: | "Rafal Maj" <maj_rafal AT poczta DOT onet DOT pl> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | static |
Date: | Thu, 3 May 2001 13:05:26 +0200 |
Organization: | Academic Computer Center CYFRONET AGH |
Lines: | 31 |
Message-ID: | <9cre3n$4bq$1@info.cyf-kr.edu.pl> |
NNTP-Posting-Host: | d-94-53-21.cyfronet.krakow.pl |
X-Trace: | info.cyf-kr.edu.pl 988887992 4474 149.156.1.181 (3 May 2001 11:06:32 GMT) |
X-Complaints-To: | news AT cyf-kr DOT edu DOT pl |
NNTP-Posting-Date: | Thu, 3 May 2001 11:06:32 +0000 (UTC) |
X-Priority: | 3 |
X-MSMail-Priority: | Normal |
X-Newsreader: | Microsoft Outlook Express 5.00.2615.200 |
X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2615.200 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
(Please, I need to get answer fast - if You can help me) I didn't use static for long time, so I have totaly forgoten how to use it :-( Why this code : class cA { private : static int a; public : static void f(); }; void cA::f() { a=3; } int main() { } gives me this error message : Creating: a.exe Error: a.o: In function `cA::f(void)': Error: a.cc(.text+0x5): undefined reference to `cA::a' Error: collect2: ld returned 1 exit status Why after moving body of static function inside class definition everything is allright : class cA { private : static int a; public : static void f() { a=3; }; // ok }; // void cA::f() { a=3; } - error int main() { } How to write this small example correct ? I must have funciton body outside of class definition, because I want this class to be splited into .cc and .h Thanks in advice....
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |