Consider the below simple example:
class base{
public:
void func(){
cout<<"Base class no arg"<<;
}
};
class derived: public base{
public:
void func(int x){
cout<<"Derived class 1 arg"<<endl;
}
};
When I make an object of derived class and call the function func without any parameter, should it not call the func defined in base class?
derived d1;
d1.func();
I get the following error:
error: no matching function for call to 'derived::func()'
Can anyone please explain why this behavior exists?