Debugging Style

For the CS4510 course, you will need to develop a strong and consistent debugging style.  You must describe your own macro set (perhaps eventually a debug class in C++) to enable macro defined debugging statements to be expanded or left as empty statements as controlled by the user.

As an example, the following is a simple macro defining a debug statement:
 

#ifdef DEBUG
#define Tdebug(stmts) { stmts; }
#else
#define Tdebug(stmts)  ;
#endif

This allows the user to #define DEBUG in order to have debug statements expanded.  E.g., a complete code using this would be:
 

#include <iostream.h>
#include <assert.h>

#define DEBUG

#ifdef DEBUG
#define Tdebug(stmts) { stmts; }
#else
#define Tdebug(stmts)  ;
#endif

main()
{
  int i,j,n;

  cin >> n;
  assert(n<100);
  for (j=0; j<n; j++){
    for (i=0; i<n; i++){
      if (i>4){
 cout << "Exiting" << endl;
 break;
      }
Tdebug(
       cout << "i = " << i << endl
      );
    }
  }
}