Dear Janathan and others, I changed my func to : ////////////////////////////// template <class T> static Class *makeInstance(T *_class,string _event,Method _method,Class* _instance_class,ReturnType _returnType,Parameter1 parameter1 = 0,Parameter2 parameter2 = 0, Parameter3 parameter3 = 0, Parameter4 parameter4 = 0) { typedef typeof(_class) _Class ; typedef EventHandlerAbstract<_Class, ReturnType, Parameter1, Parameter2, Parameter3, Parameter4> _callback; _Class _instance(1); _callback classPointer(&_instance, &_method); EventHandlerAbstract::callback_list.push_back(std::pair< int ,void* >( EventHandlerAbstract::callback_list.size()+1 , static_cast<void*>(&_instance))); EventHandlerAbstract::event_list.push_back(std::pair< int ,void* >( EventHandlerAbstract::event_list.size()+1 , &_event )); return _instance_class; ////////////////////////////////// EventHandlerAbstract is same Myclass, It's so compiled, But when i called it such as following: ////////////////////////////////////////////////////////////// test ptr = test(); EventHandlerAbstract<ptr,int,int,int,int,int>::makeInstance(test,(string)"call",test::caller(),&ptr,bool); //////////////////////////////////////////////////////////////// I get the following errors: ////////////////////////////////////////////////////////////////// main.cpp:15:25: error: ‘ptr’ cannot appear in a constant-expression main.cpp:15:48: error: template argument 1 is invalid main.cpp:15:69: error: expected identifier before ‘(’ token main.cpp:15:77: error: expected ‘,’ or ‘...’ before string constant main.cpp:15:109: error: invalid type in declaration before ‘;’ token //////////////////////////////////////////////////////////////// By the way, I define my class with the following template: /////////////////////////////////////////////////////////// template < class Class, typename ReturnType,typename Parameter1 = void , typename Parameter2 = void, typename Parameter3 = void, typename Parameter4 = void > class EventHandlerAbstract {... } //////////////////////////////////////////////////// Thank you so for much..... --mohsen On Mon, 2012-07-09 at 09:13 +0100, Jonathan Wakely wrote: > On 9 July 2012 09:03, Mohsen Pahlevanzadeh wrote: > > I changed the given func to the : > > /////////////////////////////////// > > template <class T,class MyCLass> > > Class *makeInstance(T *_class,Method _method,Class* _instance_class,ReturnType _returnType,Parameter1 parameter1,Parameter2 parameter2, Parameter3 parameter3, Parameter4 parameter4){ > > typedef (&_class) __class ; > > 1) __class is not a legal name, do not use names containing a double > underscore, or names beginning with underscore followed by uppercase > letter, they are reserved for the implementation. > > 2) &_class has type T**, i.e. it is the address of a pointer, it's not > a type, let alone a class type. > > Surely the type you want is named by one (or both) of the template > parameters T and Class.
Attachment:
signature.asc
Description: This is a digitally signed message part