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

From: "Phlip" <see AT web DOT page>
Newsgroups: comp.os.msdos.djgpp,comp.lang.c++
Subject: Re: Help : warning invalid initializer
Date: 23 May 1999 19:09:41 PDT
Organization: Concentric Internet Services
Lines: 45
Message-ID: <7iacd5$n7v@journal.concentric.net>
References: <374898C3 DOT AD7EB7FC AT netvigator DOT com>
NNTP-Posting-Host: tegan.deltanet.com
X-Newsreader: Microsoft Outlook Express 4.72.3110.5
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

NG Chi Fai wrote:

>IOTable.hpp:11: ANSI C++ forbids in-class initialization of
non-const
>static member `IOTableIdentifiers'

>class IOTable
>{
> private:
> static const char*
>IOTableIdentifiers[]={"A","B","C","D","E","F,"G","H","I","J","K","L
","M","N","O","P",NULL};


ISO C++ lets one decare a static constant in a header:

    static int const MY_FAVORITE_NUMBER (42);

But your variable is not const; the compiler would accept this line:

    IOTable::IOTableIdentifiers[0] = "Z";

Your _first_ 'const' only means the compiler will not permit this
line:

    IOTable::IOTableIdentifiers[0][0] = 'Z';

> static const char* const IdentifierSuffix="_S";

By contrast, 'IdentifierSuffix' is elegible because the pointer
itself is constant.

>};

In the words of the Good Witch of the North, "You had the answer
with you all the time, only you had to learn it for yourself!"


--
 Phlip at politizen dot com                  (address munged)
======= http://users.deltanet.com/~tegan/home.html =======
  --  The object of the game is to transfer the
        project's Critical Path to a colleague  --


- Raw text -


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