So here is code sample. The task was to give output that this code will print out. Is it 2 different functions? What happens with vtable in B class then? Does it just store 2 pointers on 2 different functions with same name?
#include<iostream>
#include <vector>
using namespace std;
class A
{
public:
A()
{
init();
}
virtual void init(bool a = true)
{
if(a)
cout << "A" << endl;
}
};
class B :public A
{
public:
virtual void init()
{
cout << "B" << endl;
}
};
int main()
{
B b;
A* a = &b;
a->init();
a->init(true);
system("pause");
}
Couldn't really find where to read about this case. Could you mates explain or give a link to some source if you've seen this case?