public base class

E

ET2 Ng

Hi all,

If I recall correctly, the functions inherited from a base class are
private in the derived class.

I want to expose some of them (but not all of them) directly through my
derived class. In other words, I'm trying to avoid something like:

void PublicFunction_DerrivedClass()
{
PublicFunction_BaseClass();
}

I would appreciate any help.
--

Best wishes,
Allen

No SPAM in my email !!
 
J

Jacques Labuschagne

ET2 said:
Hi all,

If I recall correctly, the functions inherited from a base class are
private in the derived class.

I want to expose some of them (but not all of them) directly through
my
derived class. In other words, I'm trying to avoid something like:

void PublicFunction_DerrivedClass()
{
PublicFunction_BaseClass();
}

I would appreciate any help.

That all depends on what kind of inheritance you use. The default for
classes is private inheritance, and the default for structs is public
inheritance.
To use public inheritance for classes, do something like this:

class A{
public:
void foo();
};
class B: public A{
};

int main(){
B b;
b.foo();
}
 
E

ET2 Ng

Hi John, Jacques, all,

Aha! Exactly what I was looking for! Thanks a bunch; I knew there had
to be a way to do that!
--

Best wishes,
Allen

No SPAM in my email !!
 

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
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top