fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int add(int a, int b){
  5. return a+b;
  6. }
  7.  
  8. float add(float a, float b){
  9. return a+b;
  10. }
  11.  
  12. int add(int a, float b){
  13. return a+b;
  14. }
  15.  
  16. float add(int a, int b){
  17. return a+b;
  18. }
  19.  
  20.  
  21. int main() {
  22. v=add(1,6);
  23. z=add(1.3,7);
  24. c=add(1.1,4.5);
  25.  
  26. cout <<v<<","<< z << "," << c <<endl;
  27. return 0;
  28. }
Compilation error #stdin compilation error #stdout 0s 4576KB
stdin
Standard input is empty
compilation info
prog.cpp:16:7: error: ambiguating new declaration of ‘float add(int, int)’
 float add(int a, int b){
       ^~~
prog.cpp:4:5: note: old declaration ‘int add(int, int)’
 int add(int a, int b){
     ^~~
prog.cpp: In function ‘int main()’:
prog.cpp:22:2: error: ‘v’ was not declared in this scope
  v=add(1,6);
  ^
prog.cpp:23:2: error: ‘z’ was not declared in this scope
  z=add(1.3,7);
  ^
prog.cpp:24:2: error: ‘c’ was not declared in this scope
  c=add(1.1,4.5);
  ^
prog.cpp:24:15: error: call of overloaded ‘add(double, double)’ is ambiguous
  c=add(1.1,4.5);
               ^
prog.cpp:4:5: note: candidate: ‘int add(int, int)’
 int add(int a, int b){
     ^~~
prog.cpp:8:7: note: candidate: ‘float add(float, float)’
 float add(float a, float b){
       ^~~
prog.cpp:12:5: note: candidate: ‘int add(int, float)’
 int add(int a, float b){
     ^~~
stdout
Standard output is empty