🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Can I declare private constants?

#2184
From: Kevin Ingalls
Date: Sat, 14 Oct 1995 04:45
38 lines
1361 bytes
Steven wrote:

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

I assume that what you are really asking is "how can I accomplish this
with legal syntax?" Given that, try this:

class X
{
	X() : fifty(50) {};
private:	// private, public, or protected actually has nothing to do with it
	const int fifty;
};

-or-

class X
{
	X();
private:
	const int fifty;
};

X::X() : fifty(50)
{
}

Hopefully, I answered your question.

Kevin Ingalls, (206)773-9404, ingkl900@ccmail.ca.boeing.com
---
[ 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: <DGEFp4.IBC@bcstec.ca.boeing.com>
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: 14 Oct 95 04:45:54 GMT
Approved: fjh@cs.mu.oz.au
Newsgroups: comp.std.c++
From: Kevin Ingalls <ingkl900@ccmail.ca.boeing.com>
Subject: Re: Can I declare private constants?
Message-ID: <DGEFp4.IBC@bcstec.ca.boeing.com>
Organization: Boeing Defense & Space Group Training
References: <9509118134.AA813443405@intugate.intuit.com>
X-Original-Date: Fri, 13 Oct 1995 18:07:51 GMT
X-Mailer: Mozilla 1.1N (Macintosh; I; PPC)
X-Auth: PGPMoose V1.0 PGP comp.std.c++
 iQBFAgUBMH9AoOEDnX0m9pzZAQFqUgF8Dr13H/x5fbp9km6wVWZGwivlrAP8/oLn
 joHUqIdpmItMogJVlY0YyGDSOniVoxU9
 =rDxu