Programming with Passion

Make the best out of everything.

Wednesday 16 March 2016

How to print "Something" with empty main in C++?

How to print "Something" with empty main in C++?


Write a C++ program with empty main. Its not allowed to write anything in main().
Solution:- The idea is to create a class, have a cout statement in constructor and create a global object of the class. When the object is created, constructor is called and "Something" get printed.
class hackers
{
public:
    hackers()
    {
        cout <<"Something";
     }
}m;

int main()
{

}

No comments:

Post a Comment