How and when would I call a super class method? Please referr to code segment for the two options:
class SuperClass {
public:
void method();
};
class SubClass : public SuperClass {
public:
void someOtherMethdo(){
this->method();
SuperClass::method();
}
};
using
this->method()you call a function that is either implemented in your superclass, either by your own class.When using
superClass::method(), you make sure to call the one implemented by your parent.This sample code will output