#include <iostream>
using namespace std;

class myforloop
{
public:

  int state;

  myforloop()
  { 
    cout << "constructor" << endl;
    state=0; 
  }

  void reset()
  {
    cout << "reset()" << endl;
    state=0;
  }
  bool const operator ! ()
  {
    cout << "!()" << endl;
    return (state<5);
  }
  void operator ++ ()
  {
    cout << "++" << endl;
    ++state;
  }
};

void test01()
{
  myforloop i;
  for (i.reset(); !i; ++i)
  {
    cout << "i state=" << i.state << endl;
  } 
}


int main(int argc, char** argv)
{
  test01();

  return 0;
}


