Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!apple!fernwood!portal!cup.portal.com!wmmiller From: wmmiller@cup.portal.com (William Michael Miller) Newsgroups: comp.lang.c++ Subject: Re: Static consts within classes? Message-ID: <31208@cup.portal.com> Date: 27 Jun 90 23:42:31 GMT References: <10460@batcomputer.tn.cornell.edu> <274@taumet.com> Organization: The Portal System (TM) Lines: 19 I fully agree with nearly everything Steve Clamage says in his comments to Piercarlo Grandi (). There is one point in his example that needs some correction, though: > file mystruct.c: > #include "mystruct.h" > static const int mystruct::j = 1; // initialized here only > static int mystruct::k = 2; // initialized here only Both of the "static" modifiers in the definitions are incorrect. If allowed, "static" in the definition would mean that the member had internal linkage, which contradicts the statement in the ARM, section 9.4, that "static members of a global class have external linkage." The correct rule for static members (data and functions) is to put the "static" modifier in the class declaration and omit it in the definition. (See a bit later on in that chapter for examples of correct definitions of static members.) ----------------------------------------------------------------------------- William M. Miller, Glockenspiel, Inc.; P. O. Box 366, Sudbury, MA 01776-0003