Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

“ambiguous Functions”

+1 vote
asked Sep 7, 2022 by vignesh (130 points)

i want to make “ambiguous Functions” error program in c++

1 Answer

0 votes
answered Sep 11, 2022 by xDELLx (10,520 points)

/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <iostream>

using namespace std;

void add (int x,int y){
    std::cout << "In func add(int,int) \nSum = " <<x+y<<std::endl;
}


void add (double x,double y){
    std::cout << "In func add(double ,double) \nSum = " <<x+y<<std::endl;
}

int main()
{
    cout<<"Hello World";
    add(1,2.3);

    return 0;
}

/***************************

main.cpp: In function ‘int main()’:

main.cpp:25:14: error: call of overloaded ‘add(int, double)’ is ambiguous
     add(1,2.3);
              ^
main.cpp:13:6: note: candidate: void add(int, int)
 void add (int x,int y){
      ^~~
main.cpp:18:6: note: candidate: void add(double, double)
 void add (double x,double y){

***************************/

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...