🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Scope of static member initializers

#247
From: The Apathist
Date: Thu, 02 Aug 1990 21:42
34 lines
1657 bytes
The counterexample Mike Lijewski proposes to my claimed problem with
the C++ definition compiles correctly on my CFront -- however, this
example does not:

(I've also reworked the example to clarify the reason that this
construction be appropriate.  Imagine a bounded integral type, with
distinguished constants for the min and max.)

class bounded {
    public:
    	static const bounded min;
    	static const bounded max;
    private:
    	int p;
 	static const int maxp;
    	bounded(int x) { p = x; }
};

const int bounded::maxp=3;

const bounded bounded::min=0;
const bounded bounded::max=maxp;

My CFront declares the last line invalid, saying that maxp is not
defined.  But now the problem is not so clear-cut to me; perhaps this
implementation is wrong?

Also, I implied in the original article that aggregate initialization
is not allowed for classes.  To clarify, it is allowed for classes
that have no base classes, private or protected members, and no
virtual functions, but not otherwise.

					--Tom Lippincott
					  lippin@math.berkeley.edu
Technical Details
Message-ID: <1990Aug2.214222.14165@agate.berkeley.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!agate!ragu!lippin
References: <1990Aug1.030632.2273@agate.berkeley.edu> <10603@batcomputer.tn.cornell.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!agate!ragu!lippin
From: lippin@ragu.berkeley.edu (The Apathist)
Newsgroups: comp.std.c++
Subject: Re: Scope of static member initializers
Message-ID: <1990Aug2.214222.14165@agate.berkeley.edu>
Date: 2 Aug 90 21:42:22 GMT
References: <1990Aug1.030632.2273@agate.berkeley.edu> <10603@batcomputer.tn.cornell.edu>
Sender: usenet@agate.berkeley.edu (USENET Administrator;;;;ZU44)
Reply-To: lippin@math.berkeley.edu
Organization: Authorized Service, Incorporated
Lines: 34