Open In App
Related Articles

Algorithms Quiz | SP Contest 3 | Question 9

Improve Article
Improve
Save Article
Save
Like Article
Like

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

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 25 Jul, 2018
Like Article
Save Article
Previous
Next
Similar Reads