Hi Folks,
My understanding is that to overload functions across class, the base class's function must be declared in the derived class and then it would allow me to overload a function. But the below code is not compiling. Any help in this direction would be appreciated.
Code:
#include <iostream>
using namespace std;
class A
{
public:
void hello(int i);
};
class B : public A
{
public:
void A::hello(int);
void hello(char *ch);
};
void A::hello(int i)
{
cout << "Value of int is i " << i << endl;
}
void B::hello(char *ch)
{
cout << "Value of char is " << *ch << endl;
}
int main()
{
B b1;
b1.hello((int) 10);
char ch = 'A';
b1.hello((char*) &ch);
return 0;
}