Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!mcsun!ukc!servax0!sersun1!whisd From: whisd@sersun1.essex.ac.uk (Whiteside S D B) Newsgroups: comp.lang.c++ Subject: C++ Static Members and Inheritance Keywords: C++ Static Members Inheritance Message-ID: <5069@servax0.essex.ac.uk> Date: 30 Apr 91 12:49:53 GMT Sender: news@servax0.essex.ac.uk Reply-To: whisd@essex.ac.uk (Whiteside S D B) Distribution: all Organization: University of Essex, Colchester, UK Lines: 22 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? My two objects were not of class "base" but of classes "derived1" and "derived2" respectively. I expected each object of Derived1 to have the same data member inherited from base class, and likewise for Derived2, but not that all objects of BOTH classes would have the same. 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). Any suggestions or corrections welcome. Simon Whiteside