home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!microsoft!hexnut!jimad
- From: jimad@microsoft.com (Jim Adcock)
- Subject: Re: static members in derived classes
- Message-ID: <1992Dec16.192147.1378@microsoft.com>
- Date: 16 Dec 92 19:21:47 GMT
- Organization: Microsoft Corporation
- References: <1992Dec12.175244.17775@taumet.com> <1992Dec14.215407.21631@microsoft.com> <1992Dec15.150612.28264@wam.umd.edu>
- Lines: 44
-
- In article <1992Dec15.150612.28264@wam.umd.edu> krc@wam.umd.edu (Kevin R. Coombes) writes:
- |I don't see how it follows that allowing "virtual static" data dictates
- |a particular implementation.
-
- If you are not presuming a particular implementation of virtual statics,
- consider then an implementation that implements them in a manner as-if similar
- to the following:
-
- #include <stdio.h>
-
- class A
- {
- static int _a;
- public:
- int& s;
- protected:
- A(int& aa) : s(aa) {}
- public:
- A() : s(_a) {}
- };
- int A::_a = 1;
-
- class B : public A
- {
- static int _b;
- public:
- B() : A(_b) {}
- };
- int B::_b = 2;
-
- main()
- {
- A a;
- B b;
-
- printf("a.s = %d, b.s = %d\n", a.s, b.s);
-
- return 0;
- }
-
- ======
-
- But, this particular implementation is *already* available to you,
- and far from hard to program.
-