- Define a class and in the constructor print "Hello C++"
- Instantiate the class at the time of the definition so that it executes before the main.
Sample code
#include <iostream>
using namespace std;
class MyClass
{
public:
MyClass()
{
cout << "Hello C++";
}
} myclass;
int main()
{
}