🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

3 total messages Started by nicolas (n.) chapados Tue, 24 Oct 1995 14:12
Re: Can I declare private constants?
#2292
Author: 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. ]
Re: Can I declare private constants?
#2299
Author: Ralph Shnelvar
Date: Wed, 25 Oct 1995 14:24
14 lines
1026 bytes
PMFJI,

I've been following this thread for a while (but not, obviously, from
the beginning), and I don't understand why you guys aren't using the
"enum hack" to simulate a class static constant?


Ralph Shnelvar
President
TAPEDISK Corporation
---
[ 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. ]
Re: Can I declare private constants?
#2303
Author: Tony Cook
Date: Thu, 26 Oct 1995 02:05
16 lines
1186 bytes
Ralph Shnelvar (ralphs@tesser.com) wrote:
: PMFJI,

: I've been following this thread for a while (but not, obviously, from
: the beginning), and I don't understand why you guys aren't using the
: "enum hack" to simulate a class static constant?

Because that's what it is, a hack.

-- 
        Tony Cook - tony@online.tmx.com.au
                    100237.3425@compuserve.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. ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads