inheritage: possible to call the original function ?

M

mandatory

hi,

i have two classes:

class A
{
public:
virtual Push (void *p);

};

And the other one:

Class B : Public A
{
public:
virtual Push (void *p);
}


What i want to do in the Push() in class B, is that i want to do some
additional checking in the start of the function - and the i would like to
call the original code for Push().

Is that possible, can i somehow call the original Push() (the one definded
in ClassA) ? the problem im facing is ofcourse, that when i overrides the
code for Push() it will override it all, so i have to duplicate the code if
i want it to work.

Hope you can understand - and hope you can help - thanks :)
 
A

Alf P. Steinbach

* mandatory:
class A
{
public:
virtual Push (void *p);

};

And the other one:

Class B : Public A
{
public:
virtual Push (void *p)

{
A::push( p );
}
 
K

Karl Heinz Buchegger

mandatory said:
hi,

i have two classes:

class A
{
public:
virtual Push (void *p);

};

And the other one:

Class B : Public A
{
public:
virtual Push (void *p);
}

What i want to do in the Push() in class B, is that i want to do some
additional checking in the start of the function - and the i would like to
call the original code for Push().

Is that possible, can i somehow call the original Push() (the one definded
in ClassA) ?

Yep.

void B::push( void* p)
{
...
A::push( p );
}
 

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,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top