🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Can I declare private constants?

#2292
From: nicolas (n.) chapados
Date: Tue, 24 Oct 1995 14:12
31 lines
1528 bytes
miker3@ix.netcom.com (Mike Rubenstein) wrote:
>Why must it be defined in only one place.  Consider
>
>	class A
>	{
>	  public:
>	    static const int c = 1;
>	    void f()
>	    {
>	      static const int i = 1;
>	      ...
>	    }
>	}
>
>in a header.
>
>The compiler must create only one copy of i no matter how many
>translation units include the header.  Why can't the mechanism that
>does this also be used for c?

Likewise, the compiler already ensures that the vtable for a class is
defined only once in a program (cfront-based compilers typically define
the vtable in the same translation unit defining the first virtual
function of a class.)  Could a similar mechanism be used for defining
constants?

	Nicolas Chapados
---
[ 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: <46inin$rhv@bmtlh10.bnr.ca>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 24 Oct 95 14:12:30 GMT
Approved: fjh@cs.mu.oz.au
X-Original-Date:  Tue, 24 Oct 1995 12:52:39 +0000
From: "nicolas (n.) chapados" <chapados@bnr.ca>
Message-ID: <46inin$rhv@bmtlh10.bnr.ca>
Subject:  Re: Can I declare private constants?
Newsgroups: comp.std.c++
Organization: Bell Northern Research
X-Mailer: Mozilla 1.1 (X11; I; HP-UX A.09.05 9000/712)
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMIz1v+EDnX0m9pzZAQGzXQF9GItjkHbfBuCSuVDbSr8qwu5Vo4CUwcUi
 MxhcxdH9ezMj3f5XpVFLeJ3d9qgH5ACC
 =AC24