Skip to content
Related Articles

Related Articles

Algorithms Quiz | SP Contest 3 | Question 9
  • Last Updated : 25 Jul, 2018

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

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :