[aspectc-user] aspect inheritance

Jamal Siadat siadat at cpsc.ucalgary.ca
Thu Jul 14 00:18:15 CEST 2005


Hi,
I have tried to add a methods to a class using aspects. It works really
fine when the constructor of the class that I'm adding the methods to does
not take any arguments. But When the constructor is taking arguments for
some reason the weaving process is not performed correctly. Here is an
example of what I mean:

aspect file (asp.ah):


aspect asp :public A {
pointcut calls()=  "A" ;
advice calls() :   void initialize () {p=0;j=0;}
};

A.h:
class A {
 public:
    A(int x);
  int j;
  int a(const char *name, float b);
 private:
  int p;
};

A.cc:

A::A(int x) {j=x; }

int A::a( const char *name, float b) {
  int jam=7;
return jam;
}

int main (){
  A b(5);
  return 0;}

now if you run "ag++ -o t A.cc -a asp.ah" the weaving process works fine
but you'll have the following c++ errors:

asp.ah:7: error: base `A' with only non-default constructor in class
without a constructor
: In static member function `static asp* asp::aspectof()':
:4: error: no matching function for call to `asp::asp()'
asp.ah:7: error: candidates are: asp::asp(const asp&)

does anyone know how to get around this? I know you can remove public A
and then it wont give you this error but you wont be able to access the
variables in A! so I need to inherite A.

Thanks in advance







More information about the aspectc-user mailing list