🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: No way to define some extern consts?

#3683
From: Harlan Messinger
Date: Fri, 15 Mar 1996 07:40
29 lines
1695 bytes
scott douglass (sdouglas@armltd.co.uk) wrote:
: Hello all,
: 
: Given a class type with only a no-argument contstrutor:
: 
: struct T { T(); /* ... */ };  // assume no other ctors
: 
: Is there any way to define an extern const object of class T?
: 
: extern const T t; // nope:  this is a declaration
: const T t2; // nope:  this is a definition, but t2 is not extern

This is the correct one. The object ISN'T external from the point of view 
of the module in which it's defined! You'll declare

	extern const T t2;

in the header file, but define

	const T t2;

as a global non-static object in the one source file in which you want it
to reside. 
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
Technical Details
Message-ID: <4iat2h$pk5@clarknet.clark.net>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
References: <sdouglas-1403961511440001@193.131.176.202>

Show Full Headers
Complete Article Headers
From: gusty@clark.net (Harlan Messinger)
Message-ID: <4iat2h$pk5@clarknet.clark.net>
X-Original-Date: 15 Mar 1996 04:52:33 GMT
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 15 Mar 96 07:40:07 GMT
Approved: fjh@cs.mu.oz.au
Newsgroups: comp.std.c++
Subject: Re: No way to define some extern consts?
Organization: Clark Internet Services, Inc., Ellicott City, MD USA
References: <sdouglas-1403961511440001@193.131.176.202>
X-Newsreader: TIN [UNIX 1.3 950726BETA PL0]
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMUke6+EDnX0m9pzZAQG85QF9HVS/M0/QXsSo+Vhk3OeT14Hl6Ndlk97u
 zw9s/6xcjoJbrSoWJUth3Gy9/qnMNfd2
 =uSw0