Complete listing of Hello2.cpp

/*File:  Hello2.cpp
This C++ program illustrates the basic structure 
of a C++ program that prohibits the use of global
variables and global functions other than main, 
and also avoids the use of static functions for 
any purpose other than to control the flow of 
the program acting as a pseudo main function.

It also illustrates the instantiation of an 
object of a class in dynamic memory along with 
the invocation of an instance function belonging
to that object.

The program displays the following text on the
screen:

Hello World

************************************************/

#include <iostream>
using namespace std;

class Hello2{ 
  public:
  static void classMain(){
    //Instantiate an object of the Hello2 class 
    // and save its reference in a pointer 
    // variable.
    Hello2* ptrToObject = new Hello2();
    //Now invoke the instance function named 
    // doSomething belonging to the object.
    ptrToObject -> doSomething();

  }//End classMain function
  //-------------------------------------------//

  //An instance function belonging to the Hello2
  // object.
  void doSomething(){
    cout << "Hello World\n";
  }//end doSomething function
};//End Hello2 class
//---------------------------------------------//

int main(){
  Hello2::classMain();
  return 0;
}//end main

Listing 4