If we create an object pointer to base class class which points to its child class object then we use virtual key word for late binding So.,in case of late binding,, our code goes like this :-
#include<iostream>
using namespace std;
struct A{
virtual void print() {
cout<<"function1";
}
};
struct B : public A{
void print(){
cout<<"function2";
}
};
struct C : public B{
void print(){
cout<<"function3";
}
};
int main(){
A* a = new C();
A* p = new B();
a->print();
p->print();
}
Now my question is : when we use virtual keyword in base class, all the functions of derived classes created in base class will become virtual. In multilevel inheritance, is there any way so that we can stop the function of class c from being virtual?? Any way to break this chain of virtual functions ? Sorry for any mistakes in question but i tried my best.. ☺️☺️