
/* Examples of global variables */
char chr = 'r';
int g0 = 0;

 
/** An example of a simple class definition **/
class GEN {
   int a0;
   int a2;
   char *a1;
public:
   GEN(){a0 = 23; a1="CCCLOOK"; a2 = 99;};
   ~GEN(){};
   void  Seta0(int g) { a0 = g;};
   void  Seta2(int g) { a2 = g;};
   void  Seta1(char* g) { a1 = g;}; 
   void  af(int);
};

GEN aobj;

void GEN::af (int j) {
   a0 = j;
   a2 = a0 - 1 ; 
   g0 = a0 * a2 + 34 ;
}


/**** A function using GEN Class ***/
void GEN_func(int i, char *s) {
   GEN alobj;
   int l0 = 1;

   alobj.Seta1(s);
   aobj.Seta1(s);
   aobj.Seta2(i);
   l0 = g0;
}


/*** An example of vector new and delete operation ****/

class VEC_A {
   char s[20];
   int i;

public:
   VEC_A(){ i = 10;};
   ~VEC_A(){};	
};


/*** VEC_B is a subclass of class VEC_A  ***/
class VEC_B : virtual public VEC_A {
   int j;
public:
   VEC_B(){ j = 20 ;};
   ~VEC_B(){};
};


/*** A function using vector new and delete operations **/
void VEC_func() {
   VEC_B *bp = new VEC_B [10];
   delete [] bp;

   VEC_B *bp2 = new VEC_B [5];
   delete bp2;	

   VEC_B *bp3 = new VEC_B [3];
   delete [2] bp3;

   VEC_A *ap = new VEC_A [2];
   delete [] ap;
}



/****An example of virtual functions. ***/

class VRT_A {
   int a ;
public:
   virtual void vf(){};
   virtual void vf2(){};
};

class VRT_B : public VRT_A {
   int b;
public:
   void vf(){ b = 88;};
};


void VRT_func() {
   VRT_A aobj;
   VRT_B bobj;
}

extern "C" {
   int main(void);
}

/*** Main function ***/
int main(void) {
   int aux;
   char* ptr = "LOOK";
   GEN genobj;
   VEC_B  vecbobj ; 
   VRT_B vrtbobj ;
 
   GEN_func(aux,ptr);
   VEC_func();
   VRT_func();
}
