www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/29/23:08:56

Message-ID: <37C98CD6.E5F38FEC@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> <37C1A47D DOT 40442E34 AT NortelNetworks DOT com> <37c2cd61 DOT 5065024 AT news DOT kfunigraz DOT ac DOT at>
Lines: 43
Date: Sun, 29 Aug 1999 23:54:39 GMT
NNTP-Posting-Host: 198.164.188.196
X-Trace: news20.bellglobal.com 935970879 198.164.188.196 (Sun, 29 Aug 1999 19:54:39 EDT)
NNTP-Posting-Date: Sun, 29 Aug 1999 19:54:39 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:

> >> i used to define my constants like this, following advice by someone
> >> who seemed to understand the ansi/iso c++ declaration:
> >> class c{
> >>
> >>   const char cszText[] = "Text";
> >>   const int ciNumber = 5;
> >
> >    Why would you want to have constant member variables?  I think you
> >should be using constant static member variables.
> thanks for trying to help me, but i tried your proposition and it
> resulted in an internal compiler error - see dump...

Here is some source that I've tried compiling and it compiles fine under gcc
2.95, and it does what you wanted.

#include <iostream.h>

class c {
 public:
 static const char cszText[];
 };

const char c::cszText[] = "Text";

int main(int argc, char *argv[])
{
 c test;
 cout << test.cszText;
 return 0;
}


--
     (\/) Endlisnis (\/)
          s257m AT unb DOT ca
          Endlisnis AT HotMail DOT com
          ICQ: 32959047




- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019