Cast
#include <iostream>
class baseClass {
int var_base;
public :
void whatIsThis() {
std::cout << "baseCalss" << std::endl;
}
};
class derivedClass : public baseClass{
int var1 = 3;
public :
void whatIsThis() {
std::cout << "derivedClass" << std::endl;
}
void derivedFunc() {
std::cout << var1 << std::endl;
}
};
int main () {
baseClass base_class;
derivedClass derived_class;
baseClass *b_p = &derived_class;
b_p->whatIsThis();
derivedClass *d_p = static_cast<derivedClass*>(&base_class);
d_p->whatIsThis();
d_p->derivedFunc();
}