shared base object

P

pramod

Is it possible to realize shared base object (without resorting to
static)?
What i mean is a different base objects (of same type), each of which
can be shared across multiple derived classes (objects) in inheritance
hierarchy ?

This is like decorator, but at data level (not interface).

Does any language support such feature ?

regards,
Pramod
 
V

Victor Bazarov

pramod said:
Is it possible to realize shared base object (without resorting to
static)?
What i mean is a different base objects (of same type), each of which
can be shared across multiple derived classes (objects) in inheritance
hierarchy ?

This is like decorator, but at data level (not interface).

Does any language support such feature ?

It's an artificial singleton (well, not really, it's a counted or
registered object) model. The base class has to maintain some kind
of collection of shared objects and the derived class objects should
request an object from the base and get it (as shared).

There is no direct support for that in C++, but it is possible to
code such a model.

Victor
 
J

Jeff Schwab

pramod said:
Is it possible to realize shared base object (without resorting to
static)?
What i mean is a different base objects (of same type), each of which
can be shared across multiple derived classes (objects) in inheritance
hierarchy ?

This is like decorator, but at data level (not interface).

Does any language support such feature ?

regards,
Pramod


You mean like virtual inheritance?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,413
Latest member
KeiraLight

Latest Threads

Top