-
What is the output of this program?
#include
using namespace std;
ostream & operator<<(ostream & k, int num)
{
return k;
}
int main()
{
cout << 10 << endl;
cin.get();
return 0;
}
-
- 10
- Compilation Error
- Runtime Error
- Garbage Value
- None of these
Correct Option: B
In this program, there will arise an ambiguous overload for 10.
Compilation Error
In function 'int main()':
9:14: error: ambiguous overload for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream}' and 'int')
9:14: note: candidates are:
In file included from /usr/include/c++/4.9/iostream:39:0,