Complete listing of Errors02.cpp, Listing 2

/*File:  Errors02.cpp
This C++ program illustrates a runtime error
when an attempt is made to divide a number by

This program compiles with no problems using
VS 6.0.  However, when the program is run either
from within VS 6.0, or from a command prompt,
a Windows message appears to the effect that
an error has occurred, an error message has
been generated, and permission is requested to
send the error message to Microsoft.


#include <iostream>
using namespace std;

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

  }//End classMain function

  //An instance function of the Errors02 class
  void doSomething(){
    int temp1;
    int temp2;
    temp1 = 6;
    //temp2 = 3;//This would be OK
    temp2 = 0;//This causes a runtime error
    cout << temp1/temp2 << endl;
  }//end doSomething function
};//End Errors02 class

int main(){
  return 0;
}//end main

Listing 2