#include <stdio.h>
aspect ChildInsteadOfParent 
{

  pointcut Parent_Methods () = "% Parent_Impl::%(...)";
  pointcut Child_Methods () = "% Child::%(...)";

 //advice call(Parent_Methods()) || call (Child_Methods()):around() // Nothing is displayed
 //advice call (Parent_Methods()) :before()
  //advice execution (Parent_Methods ()) && target (Child_Methods ()):around()
  advice execution (Parent_Methods ()):around()
  {
    printf("Signature is  %s\n", JoinPoint::signature());
    tjp->proceed();
    //printf("Result is  %s\n", tjp->result());
  }
};


class Parent_Impl {
public:
  Parent_Impl();
  ~Parent_Impl();
  virtual void a1(); 
  virtual void a2(); 
  virtual void a3(); 
};

class Child:public Parent_Impl {
public:
  Child();
  ~Child();
  void a1();
  void a2();
  void a3();

};

Parent_Impl::Parent_Impl()
{
}

Parent_Impl::~Parent_Impl()
{
}

void Parent_Impl::a1()
{
 printf("parent a1\n");

}

void Parent_Impl::a2()
{
 printf("parent a2\n");
}

void Parent_Impl::a3()
{
 printf("parent a3\n");
}

Child::Child():Parent_Impl()
{
}

Child::~Child()
{
}


void Child::a1() 
{ 
    printf("child a1\n");
}

void Child::a2()
{ 
    printf("child a2\n");
}

void Child::a3()
{ 
    printf("child a3\n");
}

class Child1:public Parent_Impl {
public:
  Child1();
  ~Child1();
  void a1();
  void a2();
  void a3();

};


Child1::Child1():Parent_Impl()
{
}

Child1::~Child1()
{
}

void Child1::a1()  { printf("child1   a1\n"); }
void Child1::a2() { printf("child1   a2\n"); }
void Child1::a3() { printf("child1   a3\n"); }

int main () 
{
  //Parent_Impl *r_impl = new Child1();
  Parent_Impl *r_impl= new Parent_Impl();
  r_impl->a1();
  r_impl->a2();
  r_impl->a3();
	 
  return 0;
}
