delorie.com/archives/browse.cgi | search |
Message-ID: | <37CB013F.9766790B@unb.ca> |
From: | Endlisnis <s257m AT unb DOT ca> |
X-Mailer: | Mozilla 4.61 [en] (Win98; U) |
X-Accept-Language: | en |
MIME-Version: | 1.0 |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: c++ const definition in djgpp 2.95 problem |
References: | <37c18ffb DOT 1378453 AT news DOT kfunigraz DOT ac DOT at> <37cad280 DOT 1608331 AT news DOT kfunigraz DOT ac DOT at> |
Lines: | 54 |
Date: | Tue, 31 Aug 1999 12:19:59 GMT |
NNTP-Posting-Host: | 198.164.188.86 |
X-Trace: | news21.bellglobal.com 936101999 198.164.188.86 (Tue, 31 Aug 1999 08:19:59 EDT) |
NNTP-Posting-Date: | Tue, 31 Aug 1999 08:19:59 EDT |
Organization: | Sympatico |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
mimo wrote: > the other solution - using static member constants - differs from the > stated aim. defining a constant this way results in having more class > mebers than before (again think so...), means that static members are > simply not the same as this precompiler-"trick". > to make it clear an example: > > class c{ > static const int ciSize; > static const apszString[ciSize]; > }; > > this simply cannot be done with static members since at the time when > the precompiler (??) reaches the second const it doesn't know the > value of ciSize. i am rather sure that this is also the reason for the > internal compiler error, which could be avoided if it were still > possible to define consts the way i used to do. > maybe there is another workaround - thanks in advance. This works fine. The constants are NOT touched by the precompiler. The size does not need to be specified in the class definition. Here's an example, I tried it with v2.95 and it works. #include <iostream.h> class c { public: static const int size; static const char cszText[]; }; const int c::size = 17; const char c::cszText[c::size] = "Text"; int main() { c test; cout << test.cszText; return 0; } -- (\/) Endlisnis (\/) s257m AT unb DOT ca Endlisnis AT HotMail DOT com ICQ: 32959047
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |