I am able to invoke the private function of the derived class. Is this Ok?
#include <iostream>
class A {
public:
virtual ~A() {}
virtual void func()
{
std::cout << " Printing from A" << std::endl;
}
};
class B : public A {
private:
virtual void func()
{
std::cout<< " Printing from B"<<std::endl;
}
};
main()
{
B b;
A* a = &b;
a->func();
// b.func(); Not possible as expected.
}
Below is the output
Printing from B