473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

static member in base class

t
Lippman's C++ Primer says that if a base class defines a static data
member or method, then there is only one such member for the
inheritance hierarchy rooted at the base class.

So no matter how many objects exist in the hierarchy, they all share
the same static members? How does this work? Do they all have method
pointers all pointing to the same set of static members?

Are static members created when a program is first run and placed in a
special section of memory? I am curious about how C++ implements
things, but I never studied comp sci beyond introductory classes.

Sep 24 '07 #1
2 1741
t
On Sep 24, 8:31 am, t <tmt...@Yahoo.comwrote:
So no matter how many objects exist in the hierarchy, they all share
the same static members? How does this work? Do they all have method
pointers all pointing to the same set of static members?
I meant to say "Do they all have pointers...."

Sep 24 '07 #2
t wrote:
On Sep 24, 8:31 am, t <tmt...@Yahoo.comwrote:
>So no matter how many objects exist in the hierarchy, they all share
the same static members? How does this work? Do they all have
method pointers all pointing to the same set of static members?

I meant to say "Do they all have pointers...."
You would probably benefit from reading "Inside the C++ Object Model"
by Stanley Lippman. You seem to want to know how things work on the
inside, and that's a decent book to answer your questions.

Meanwhile, imagine that static members are just glorified globals.
The essential (the only real) difference with namespace globals is
that the names of class static data members are declared to have
access specifiers.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Sep 24 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: cppaddict | last post by:
Hi, Say I have a abstract base class and I know that every derived class will have a static data member (call it SharedInformation) representing information to be shared across all instances of...
8
by: Jon Slaughter | last post by:
Is there any way to declare a member of a base class to make the itself in the derived class to be static? i.e., I have two classes class Base { protected: char *name;
13
by: Adam H. Peterson | last post by:
I just made an observation and I wondered if it's generally known (or if I'm missing something). My observation is that static protected members are essentially useless, only a hint to the user. ...
7
by: Sunny | last post by:
Hi all, According C# Language Specification : 10.11 Static constructors: The static constructor for a class executes at most once in a given application domain. The execution of a static...
6
by: Bill Rubin | last post by:
The following code snippet shows that VC++ 7.1 correctly compiles a static member function invocation from an Unrelated class, since this static member function is public. I expected to compile the...
14
by: Dave Booker | last post by:
It looks like the language is trying to prevent me from doing this sort of thing. Nevertheless, the following compiles, and I'd like to know why it doesn't work the way it should: public class...
8
by: Per Bull Holmen | last post by:
Hey Im new to c++, so bear with me. I'm used to other OO languages, where it is possible to have class-level initialization functions, that initialize the CLASS rather than an instance of it....
15
by: Philipp | last post by:
Hello I don't exactly understand why there are no static virtual functions. I would have liked something like this: class Base{ static virtual std::string getName(){ return "Base"; } }
13
by: learning | last post by:
Hi I have a static class written by other team which encapsulates a database instance. but I need to extend it to incldue other things. I know that C# static class is sealed and can;t be inherited...
15
by: akomiakov | last post by:
Is there a technical reason why one can't initialize a cost static non- integral data member in a class?
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.