Call parent method from child, similar to calling "super" (C ++)
Is it possible to "reuse" a parent method in a child method and add functionality just like with the superoperator in Java?
parent.method(int a){
a++;
}
child.method(int a /*would be nice w/out*/){
printf("%d",a);
}
I know this is probably a pretty simple question, sorry about that.
I know I can just copy / paste the method into the child class and add functionality there by overloading; However, I am looking for a more convenient way.
+3
source to share
4 answers
You can use __ super for this, but this is a Microsoft extension.
void CChild::function( int nParam )
{
__super::function( nParam );
}
Alternatively, you can explicitly call the base implementation from the derived class:
void CChild::function( int nParam )
{
CParent::function( nParam );
}
+6
source to share