#include
class debuggable
{
public:
                virtual void dump()
                {
                                cout<<"Debuggable Error: No dump() Defined For This Class "<<endl;
                }
};

The above class saved in a file extension .h. Here, we said this file as debug.h file name. Now we can test the debug gable class in following example.

#include"debug.h"
#include
class X:public debuggable
{
                int a,b,c;
public:
                X(int aa=0,int bb=0,int cc=0)
                {
                                a=aa;
                                b=bb;
                                c=cc;
                }
                void dump()
                {
                                cout<<"A = "<<a<<"\tB = "<<b<<"\tC = "<<c<<endl;
                }
};
class Y:public debuggable
{
                int i,j,k;
public:
                Y(int ii=0,int jj=0,int kk=0)
                {
                                i=ii;
                                j=jj;
                                k=kk;
                }
                void dump()
                {
                                cout<<"I = "<<i<<"\tJ = "<<j<<"\tK = "<<k<<endl;
                }
};
class Z:public debuggable
{
                int p,q,r;
public:
                Z(int pp=0,int qq=0,int rr=0)
                {
                                p=pp;
                                q=qq;
                                r=rr;
                }
};
void main()
{
                clrscr();
                X x(1,2,3);
                Y y(2,4,5);
                Z z;
                x.dump();
                y.dump();
                z.dump();
                debuggable *dbg[3];
                dbg[0]=&x;
                dbg[1]=&y;
                dbg[2]=&z;
                cout<<"Dumping Through Passing The Same Message To All Object _ _ _ \n";
                for(int i=0;i<3;i++)                                 dbg[i]->dump();
                getch();
}
Advertisements