bruss@odin.ucsd.edu (Brian Russ) (08/22/90)
In article <ssimmons.651246617@convex> ssimmons@convex.com (Steve Simmons) writes: > > > class GROUP > { > private: > int notShared; > static int shared; > public: > GROUP() : { if (shared == 0) doFirstInstanceStuff(); }; > }; > > int GROUP::shared = 0; // Initialize here ^^^ Two questions. First, is the 'int' declaration needed here? 'shared' is already known to be an int, I thought ... Secondly (this may be GNU C++ specific) I can't get the above to work (regardless of the 'int' issue) unless 'shared' is declared as public. This seems to contradict Lippman, who says that the, uh, "see-ability" (can't think of the proper term) of a static member (i.e. is it public or private) affects access but *not* initialization. GNU C++, however, will complain about the "Initialize here" line, claiming that "shared" is a private member. Am I missing something here? -- Brian Russ CSE Department, UC San Diego ..!sdcsvax!bruss bruss@beowulf.ucsd.edu
barry@bain3.oz (Barry Allebone) (08/23/90)
In article <12372@sdcc6.ucsd.edu>, bruss@odin.ucsd.edu (Brian Russ) writes: > In article <ssimmons.651246617@convex> ssimmons@convex.com (Steve Simmons) writes: > > > <stuff deleted> > > Secondly (this may be GNU C++ specific) I can't get the above > to work (regardless of the 'int' issue) unless 'shared' is declared > as public. This seems to contradict Lippman ... > <stuff deleted> I've noticed this in Lippman too. It doesn't work with the Zortech compiler either (at least with static class objects). Steve Clamage is helping me behind the scenes via email but I too would like to see more discussion of this whole subject. The ARM is not available in Australia yet either :-(