In the below c++ code using virtual functions
#include<iostream>
using namespace std;
class Base{
public:
virtual void fun(){
cout << "Base::fun()called \n";
}
};
class Child : public Base {
public:
void fun() {
cout << "Child::fun() called\n";
}
void door(){
cout << "Child::door() called \n";
}
};
int main(){
Base *base_ptr = new Child();
base_ptr->fun();
return 0;
}
How can I invoke door function using base_ptr? This question was asked in an interview. I was wondering whether it can be possible
Thanks for your replies