I am passing different types of argument to the fun(), the code gets compiled, but still, the same function that prints "Class B" is getting executed. Shouldn't there happen overloading of functions? Why does this happen?
#include <iostream>
using namespace std;
class A
{
public:
void fun(int x)
{
cout<<"class A"<<endl;
}
};
class B: public A
{
public:
void fun (char c)
{
cout<<"Class B"<<endl;
}
};
int main()
{
B obj;
obj.fun('c');
obj.fun(3);
}