delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/09/16/04:33:55

From: hhkraemer AT web DOT de (Horst Kraemer)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: static const as array size
Date: Sun, 16 Sep 2001 08:28:18 GMT
Lines: 33
Message-ID: <3ba45d99.217604548@news.cis.dfn.de>
References: <3ba455e7 AT news DOT vogel DOT pl>
NNTP-Posting-Host: a0932.pppool.de (213.6.9.50)
X-Trace: fu-berlin.de 1000628639 10763115 213.6.9.50 (16 [27606])
X-Newsreader: Forte Free Agent 1.21/32.243
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Sun, 16 Sep 2001 09:33:01 +0200, "Raf256" <raf256 AT go2 DOT pl> wrote:

> #include <iostream.h>
> class cThrowBasic {
>   protected  :
>     static const int maxDescrLen;
>     char description[maxDescrLen];
>  public :  cThrowBasic();
> };
> const int cThrowBasic::maxDescrLen = 500;


Change this to

class cThrowBasic {
protected  :
    static const int maxDescrLen=500;
    char description[maxDescrLen];
public :
    cThrowBasic();
};
const int cThrowBasic::maxDescrLen;

The error message is somewhat cryptic. It is probably initated by the
definition of 'description' using a constant with no visible value
which should be flagged as an error. If you are using an integral
static const in the class definition you have to provide the
initialisation in the _declaration_ of the member and _not_ in the
definition.

Regards
Horst

- Raw text -


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