Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!uunet!stanford.edu!neon.Stanford.EDU!news From: philip@pescadero.stanford.edu (Philip Machanick) Newsgroups: comp.lang.c++ Subject: Re: C++ Static Members and Inheritance Message-ID: <1991Apr30.224544.15015@neon.Stanford.EDU> Date: 30 Apr 91 22:45:44 GMT References: <5069@servax0.essex.ac.uk> Sender: news@neon.Stanford.EDU (USENET News System) Organization: Computer Science Department, Stanford University Lines: 25 In article <5069@servax0.essex.ac.uk> whisd@sersun1.essex.ac.uk (Whiteside S D B) writes: >I noticed something in some classes I was producing using Borland C++ recently. > >It seems anomalous, can anyone let me know of what they think: > >I had a base class in which I declared a static data member. > >I then derived TWO separate classes which both inherited from the base class. > >Then these classes were instanstiated as objects I found that for BOTH the static data member (a pointer) had the SAME value. > >Now I know that a static member is the same for every object of a class, but is the same for every object of a DERIVED class? [...] >I've searched literature high and low for an answer to this. Nowhere do they mention what happens when you inherit a static member (data or function). > I had exactly the the same problem with AT&T cfront 2.0 last year. On a quick scan of ARM, I could find no mention of this behaviour, but lots of people assured me that this is "standard". Philip Machanick