Home » C++ Programming » Overloading » Question
  1. What is the output of this program?
    #include 
    using namespace std;
    int function(int N, int M, int O)
    {
    return N + M;
    }
    double function(double N, double M, double O)
    {
    return N + M;
    }
    int main()
    {
    cout << function(7, 16);
    cout << function(15.05, 61.16);
    return 0;
    }
    1. 7
    2. 16
    3. 15.05
    4. 61.15
    5. Compilation Error
Correct Option: E

Compilation Error

In function 'int main()':
13:31: error: no matching function for call to 'function(int, int)'
13:31: note: candidates are:
3:9: note: int function(int, int, int)
3:9: note: candidate expects 3 arguments, 2 provided
7:12: note: double function(double, double, double)
7:12: note: candidate expects 3 arguments, 2 provided
14:38: error: no matching function for call to 'function(double, double)'
14:38: note: candidates are:
3:9: note: int function(int, int, int)
3:9: note: candidate expects 3 arguments, 2 provided
7:12: note: double function(double, double, double)
7:12: note: candidate expects 3 arguments, 2 provided



Your comments will be displayed only after manual approval.