My program is:
class base {
int a, b;
public:
int add(int a, int b) {
return a + b;
}
int add(int a, int b, int c=0 ){
return a + b + c;
}
};
int main() {
base b;
b.add(10, 20);//compilation error
return 0;
}
I know there is ambiguity arise. But I want to know how a compiler works for a default argument with function overloading. Because if I'm not calling this function or call add(10,20,0) it works fine.
or
for function overloading it is treated as add(int,int),add(int ,int, int)because it has 2 different function signature but what logic behind that please explain in detail.