// interrup`t class - installs and removes a newhandler
// NOTE: Test Stack Overflow must be turned off
#if !defined (__cplusplus)
 #error compile as cplusplus
#endif

#include <dos.h>
#include <conio.h>
#include <stdio.h>

typedef   void interrupt (far *handler)(...);



class setIntr {
    private:
	int intrNo;
	handler old;
    public:
	setIntr( int intNum, handler inew, handler &iold)  {
	    intrNo = intNum;
	    iold = old = getvect( intNum );
	    setvect( intNum, inew );
	};
	~setIntr( ) { setvect( intrNo, old ); }
};


class clkInt : public setIntr {
    private:
	 void interrupt far newClock(...);
	 handler oldClock;
    public:
	 volatile int count;
	 clkInt () : setIntr (0x1c, clkInt::newClock, clkInt::oldClock) { count = 0; }
	 ~clkInt () { ; }

};





int main (void)
{
    clkInt clock();
    while (clock.count < 4)
	printf("count is %d\n",clkInt::count);

    return 0;
}




void interrupt far newClock(...)
{
/* increase the global counter */
   count++;
/* call the old routine */
   oldClock();
}

