Please look at the following code listing:
#include
using namespace std;
class Base {
public:
virtual void Message() = 0;
};
class In
In C++, virtual and access specifiers are mutually exclusive. That is the reason why in C++, the access can be narrowed for virtual methods whereas in C# or Java that is not possible.
When you try to access the virtual function through base class pointer, the compiler compiles the code since the base class' virtual function is public.
In your commented code, the virtual function having restricted access is called via the Final class pointer. Hence the compilation error.