templates and function pointers

A

Andy White

If I want a pointer to a function that returns void and takes as it's
arguments a pointer to a templatized type and a const int, does this need to
be declaired in global scope? I'm not sure of the syntax with the template
part..

template <class T>
void (*f)(T *, const int);

thanks.
 
K

Kai-Uwe Bux

Andy said:
If I want a pointer to a function that returns void and takes as it's
arguments a pointer to a templatized type and a const int, does this need
to be declaired in global scope? I'm not sure of the syntax with the
template part..

template <class T>
void (*f)(T *, const int);

thanks.

Do you want to declare a type or a variable? Anyway, neither templated
typedefs nor templated variables exist. What about:

template < typename T >
struct xxx {

typedef void (*T_function)( T*, int );

};

int main ( void ) {
xxx<int>::T_function f;
}



Best

Kai-Uwe Bux
 
A

Andy White

Kai-Uwe Bux said:
Do you want to declare a type or a variable? Anyway, neither templated
typedefs nor templated variables exist. What about:

template < typename T >
struct xxx {

typedef void (*T_function)( T*, int );

};

int main ( void ) {
xxx<int>::T_function f;
}



Best

Kai-Uwe Bux

That works great, thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top