a doubt regarding late binding

class A
{
public:
virtual int func()
{
cout << "hello"
}
}
class B: public A
{

public:
int func()
{

cout << "in class B";
}
}
int main()
{
B b;
A *a1=&b;
A &a2=b;
A a3;
A *a4=&a3;
cout << b.func() << a1->func() << a2.func() << a3.func() << a4->func();
}
My doubt in this call(a4->func()). what will take place early binding or late binding ??
I want to say that the virtual table of a3 will be consulted to find the implementation of func() to execute. This will be A::func.

However, written the way it is, I suspect this might be something optimized away by the compiler, so that in fact, no run-time binding occurs.
Last edited on
Topic archived. No new replies allowed.