What are ambiguous statements in overloaded functions in C++ ?

An  ambiguous statement is a type of an error in C++. It happens when a function is overloaded and when the function is called there is a problem with automatic type conversion.

For Example:

#include <iostream>

using namespace std;

float func(float x);

double func(double x);

int main()


cout << myfunc(6,2) << ” “;

cout << myfunc(5);

return 0;


In this Example cout << myfunc(5); is an ambiguous statement because the compiler doesn’t know whether 5 should be converted to float or double.

Leave a Reply