Open In App

Algorithms Quiz | SP Contest 3 | Question 9

Like Article
Like
Save
Share
Report

What will be the output of below C++ Program?




class Gfg
{
public:
    int main(int s)
    {
        cout << s << ", ";
        return 0;
    }
    int main(char *s)
    
        cout << s << “, ”;
        return 0;
    }
    int main(int s ,int m)
    {
        cout << s << " " << m;
        return 0;
    }
};
  
int main()
{
    Gfg obj;
    obj.main(3);
    obj.main("Hello World!");
    obj.main(9, 6);
    return 0;
}


(A) 3
(B) Error
(C) 3, Hello World!, 9 6
(D) 3, Garbage Value, 9 6


Answer: (C)

Explanation: https://www.geeksforgeeks.org/can-main-overloaded-c/

Quiz of this Question


Last Updated : 25 Jul, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads