Why does the compiler not throw error in main()
for p->f4();
line.
As per my understanding class B
hides f4()
and should throw error
class A
{
public:
void f1(){}
virtual void f2(){}
virtual void f3(){}
virtual void f4(){}
};
class B : public A
{
public:
void f1(){}
void f2(){}
void f4(int x){}
};
int main()
{
A *p;
B o2;
p = &o2;
p->f1();
p->f2();
p->f3();
p->f4(); //why doesn't it throw an error for this line as class B hides f4()
p->f4(5);
return 0;
}