473,396 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

templates and function pointers

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.
Oct 20 '05 #1
2 1218
Andy White wrote:
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
Oct 20 '05 #2

"Kai-Uwe Bux" <jk********@gmx.net> wrote in message
news:dj**********@murdoch.acc.Virginia.EDU...
Andy White wrote:
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


That works great, thanks.
Oct 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Sat | last post by:
Hi, I have a simplified version of a problem that I am facing (hope I haven't oversimplified it). This code doesn't work now and I want to find how I can make it work. Can I call the derived...
1
by: David Goodyear | last post by:
At the moment im experimenting with ideas in C++ and would really like to solve the following, please please help. Sorry i dont even know what the subject is this would come under? :( Sorry if...
4
by: | last post by:
I have these errors with code following: --------------------------------------------------------------- 'SharedObject' : use of class template requires template argument list...
4
by: Martin | last post by:
Greetings I want to have virtual member functionality, but without my member functions being virtual:-) As of yet this is all just in my head cause I can't see a nice solution yet so lets...
12
by: Ben | last post by:
I'm kind of new to creating templates. I've made some small class and function templates in the past and I have used quite of bit of the STL, but I am having problems tyring to create templates. ...
23
by: Ben Voigt | last post by:
I have a POD type with a private destructor. There are a whole hierarchy of derived POD types, all meant to be freed using a public member function Destroy in the base class. I get warning C4624....
3
by: Ernesto Bascón | last post by:
Hi everybody: I have two questions: 1. I'm using opaque pointers in my classes to hide their data structures; there is a way to use opaque pointers in template classes; since the...
2
by: Pat | last post by:
Hello everyone, I have a question that even my instructor is perplexed. I have created a template class within a header file. Then in a cpp file I have the methods that go with the class. I have...
104
by: JohnQ | last post by:
Well apparently not since one can step thru template code with a debugger. But if I was willing to make the concession on debugging, templates would be strictly a precompiler thing? I have a...
7
by: Chris | last post by:
Hi All, This is a weird one but I am hoping someone can help or has some pointers, a recipe how to do the following: I have to move some code from c++ to objective-c and to do this I must...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.