Hello All,
I am a learner in C++. I was testing my inheritance knowledge with following piece of code.
#include <iostream>
using namespace std;
class base
{
public :
void display()
{
cout << "In base display()" << endl;
}
void display(int k)
{
cout << "In base display(int k)" << endl;
}
};
class derived : public base
{
public :
void display()
{
cout << "In derive display()" << endl;
}
};
int main()
{
derived der;
der.display(50);
}
As far as I know it should compile without giving any error. But that is not the case as it is giving compilation error saying :-
StaticMember_1.cpp: In function �int main()':
StaticMember_1.cpp:30: error: no matching function for call to �derived::display(int)'
StaticMember_1.cpp:21: note: candidates are: void derived::display()
Can you guys help me out in finding why its giving error. there must be some concept here which I am missing.
Thanks in advance all of you.
Regards,
Anand Shah