🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2204

Re: Can I declare private constants?

#2204
From: Valery Croizier
Date: Sun, 15 Oct 1995 16:00
33 lines
1481 bytes
   [...]

   class X
   {
   private:
	  const int fifty = 50;
   };

   GNU C++ swallows it fine, of course.  God bless the GNU Project.

   [...]

Use the -ansi flag to make g++ as strict as any other ANSI-compliant
compiler.
	[Moderator's note: no, that's not sufficient.  You need
	to use `-pedantic' as well.  -fjh.]

If your constant is an int, then you can cheat and use an enum, and
you can use your enum like a const int whose value is know at compile-time.

	class X
	{
	private:
		enum { fifty = 50 };
	//	int tab[fifty]; // for example
	};

--
Valery
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <CROIZIER.95Oct15160809@poirot.rennes.enst-bretagne.fr>
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
References: <9509118134.AA813443405@intugate.intuit.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
Date: 15 Oct 95 16:00:42 GMT
Approved: fjh@cs.mu.oz.au
From: croizier@rennes.enst-bretagne.fr (Valery Croizier)
Newsgroups: comp.std.c++
Subject: Re: Can I declare private constants?
X-Original-Date: 15 Oct 1995 15:08:09 GMT
Organization: ENST de Bretagne, Rennes, France
Message-ID: <CROIZIER.95Oct15160809@poirot.rennes.enst-bretagne.fr>
References: <9509118134.AA813443405@intugate.intuit.com>
In-Reply-To: Steven_Boswell@intuit.com's message of 11 Oct 95 23:59:56 GMT
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMIExHeEDnX0m9pzZAQHXQwF+OfkWmetZ7wgVPxG1DNSbNx1mL0a+zSRV
 J+3FI/T46s4UkLWvZoxUfWAKqBDKzSwM
 =x3H4