[aspectc-user] Namespace problems

Liu YueChang liuyuechang at gmail.com
Sun Apr 1 12:46:45 CEST 2007

Hello everybody

Could anybody tell me how can I solve this problem? The error message
of this aspect c++ is so confused.

I just try to use aspect c++ to write factory pattern. But I can not
give the correct matching pattern because of the namespace. I think
the namespase is a big problem in Aspect C++. It always give very blur
error message.

If I compile the following sourcecode, it said "error: invalid
declaration near token `:'".

The error just occur at CConcreateFactory1::CConcreateFactory1()

Also, if I give a constructor inside the std::CAbstract, the compiler
will report that the constructor name is invalid. I really confused.

I am using aspect c++ with MinGW

Thanks a lot.


The following is my source code:

#include "CConcreateFactory1.h"
#include "CAbstractProductA.h"
#include "CAbstractProductB.h"

aspect AAbstractFactory {
	advice "std::CConcreateFactory%" : slice class : public std::CAbstract {
		virtual std::CAbstractProductA createProductA() = 0;
		virtual std::CAbstractProductB createProductB() = 0;

#include "CConcreateFactory1.h"

namespace std

	cout << "construction of CConcreateFactory1" << endl;

	cout << "destruction of CConcreateFactory1" << endl;

CAbstractProductA* CConcreateFactory1::createProductA()
    return new CProductA1();

CAbstractProductB* CConcreateFactory1::createProductB()
    return new CProductB1();

More information about the aspectc-user mailing list