   Automated counting
  I'm trying to make this program count what it's doing. Each operator will increment an int "actions". I want to be able to just include the header file and say "using namespace counter" to make the program count what it's doing. So far the code I have is partially working... and looks like a mess IMO. It's for an assignment. I got passed most of the errors but warnings still pop up like "operator<< isn't used" while it should be.So far "actions" is only incremented when operator=( Integer ) is called :( The other increments aren't working.EDIT: I outputted "actions" with couts inside the functions right after each "++actions" and it's counting... but when I get to the end of the main function and say "cout << actions" it doesn't print out the correct number. It says 14 but the output from the debugging code says 107. I don't understand.EDIT: Nevermind. I was erroneously using static just to get rid of the error messages, which caused side effects that I better understand now (thanks to google). I fixed the problems after reading this: http://ubuntuforums.org/showthread.php?t=317212Here is the code:#ifndef COUNTER_H_INCLUDED#define COUNTER_H_INCLUDED#include <iostream>namespace counter{  static unsigned actions = 0;  class Integer  {    public: Integer(): integer(){} Integer( int i ): integer( i ){} Integer( const Integer& i ): integer( i.integer ){} Integer operator+( int ); Integer operator+( Integer ); Integer operator=( int ); Integer operator=( Integer i ) {   ++actions;   integer = i.getNumber();   return *this; } Integer operator%( Integer i ) {   ++actions;   integer %= i.getNumber();   return *this; } Integer operator%( int i ) {   ++actions;   integer %= i;   return *this; } Integer& operator++(); bool operator==( int ) const; bool operator!=( int ) const; bool operator<( int ) const; bool operator==( Integer ) const; bool operator<( Integer ) const; inline int& getNumber();    private: int integer;  };  class Cout  {    public: Cout& operator<<( const char* ); Cout& operator<<( Integer& ); Cout& operator<<( int ); Cout& operator<<( std::ostream& ( *f )( std::ostream& ) );    private:  }static cout;  class Cin  {    public: Cin& operator>>( char* ); Cin& operator>>( Integer& ); Cin& operator>>( std::istream& ( *f )( std::istream& ) );    private:  }static  cin;  inline int& Integer::getNumber()  {    return integer;  }  static std::ostream& operator<<( std::ostream& argOut, counter::Integer argOutput )  {    return argOut << argOutput.getNumber();  }  static std::istream& operator>>( std::istream& argIn, counter::Integer& argInput )  {    return argIn >> argInput.getNumber();  }}// Override built-in c++ types with macros#define int Integer#endif // COUNTER_H_INCLUDEDcounter.cpp:#include <iostream>#include "counter.h"// Disable macro overrides so default types work correctly#undef intusing namespace counter;//using std::ostream;Integer Integer::operator+( Integer argInteger ){  ++actions;  integer += argInteger.integer;  return *this;}Integer Integer::operator+( int argInteger ){  ++actions;  integer += argInteger;  return *this;}Integer& Integer::operator++(){  ++actions;  ++integer;  return *this;}Integer Integer::operator=( int argInteger ){  ++actions;  integer = argInteger;  return *this;}bool Integer::operator==( int argInteger ) const{  ++actions;  return integer == argInteger;}bool Integer::operator!=( int argInteger ) const{  ++actions;  return integer != argInteger;}bool Integer::operator<( int argInteger ) const{  ++actions;  return integer < argInteger;}bool Integer::operator==( Integer argInteger ) const{  ++actions;  return integer == argInteger.integer;}bool Integer::operator<( Integer argInteger ) const{  ++actions;  return integer < argInteger.integer;}Cout& Cout::operator<<( const char* cString ){  ++actions;  std::cout << cString;  return *this;}Cout& Cout::operator<<( Integer& argInteger ){  ++actions;  std::cout << argInteger.getNumber();  return *this;}Cout& Cout::operator<<( int argInteger ){  ++actions;  std::cout << argInteger;  return *this;}Cout& Cout::operator<<( std::ostream& (*f)(std::ostream&) ){  ++actions;  std::cout << f;  return *this;}Cin& Cin::operator>>( std::istream& (*f)(std::istream&) ){  ++actions;  std::cin >> f;  return *this;}Cin& Cin::operator>>( Integer& argInteger ){  ++actions;  std::cin >> argInteger.getNumber();  return *this;}[Edited by - Recruit0 on April 26, 2009 8:16:37 PM]