Академический Документы
Профессиональный Документы
Культура Документы
file:///Users/saumitre/other/read/tech/c-func-ptrs-typedef.htm
Search Tips
TODAY'S HEADLINES | ARTICLE ARCHIVE | SKILLBUILDING | TIP BANK | SOURCEBANK | FORUMS | NEWSLETTERS
Average Rating: 4.4/5 | Rate this item | 111 users have rated this item.
Expertise: Advanced
Language: C++
March 8, 2000
Hide Function Pointer Declarations With a typedef
Can you tell what the following declaration means?
Open Source
XML
Semantic Web
VB Classic
ASP/ASP.NET
Enterprise
Mobile
Only few programmers can tell that p is an "array of 10 pointers to a function returning void and taking a
pointer to another function that returns void and takes no arguments." The cumbersome syntax is nearly
indecipherable. However, you can simplify it considerably by using typedef declarations. First, declare a
typedef for "pointer to a function returning void and taking no arguments" as follows:
Special Reports
10-Minute Solutions
DevXtra Editors' Blog
Shop DevX
Next, declare another typedef for "pointer to a function returning void and taking a pfv" based on the
typedef we previously declared:
APIfinder
Now that we have created the pf_taking_pfv typedef as a synonym for the unwieldy "pointer to a function
returning void and taking a pfv", declaring an array of 10 such pointers is a breeze:
pf_taking_pfv p[10];
Danny Kalev
If you have a hot tip and we publish it, we'll pay you. However, due to accounting overhead we no longer pay $10 for a single tip
submission. You must accumulate 10 acceptable tips to receive payment. Be sure to include a clear explanation of what the
technique does and why it's useful. If it includes code, limit it to 20 lines if possible. Submit your tip here.
DevX: C++ Zone
By raviparu
This example really helps in simplifying any sort of complex function pointer declarations
Reply to this comment
Add a comment
Enter a username
Email address (used only for verification; it will not be displayed or added to any list)
1 of 3
9/11/15, 12:13 PM
file:///Users/saumitre/other/read/tech/c-func-ptrs-typedef.htm
By raviparu
This example really helps in simplifying any sort of complex function pointer declarations
Reply to this comment
Add a comment
Enter a username
Email address (used only for verification; it will not be displayed or added to any list)
Intel Parallel Studio helps C++ developers find latent memory errors that
cause crashes and lockups Intel Parallel Studio helps C++ developers find
latent memory errors that cause crashes and lockups
Intel Parallel Studio helps C++ developers add parallelism to apps to take
advantage of multicore. Intel Parallel Studio helps C++ developers add
parallelism to apps to take advantage of multicore.
Intel Atom Developer Windows Beta 3 SDK Brings Enhancements & Component
Integration Intel Atom Developer Windows Beta 3 SDK Brings Enhancements
& Component Integration
C++ developers use Intel Parallel Studio to locate and optimize hotspots and
boost performance. C++ developers use Intel Parallel Studio to locate and
optimize hotspots and boost performance.
2 of 3
9/11/15, 12:13 PM
file:///Users/saumitre/other/read/tech/c-func-ptrs-typedef.htm
Search:
About Internet.com
Copyright 2015 QuinStreet Inc. All Rights Reserved. Copyright 2010 QuinStreet Inc. All Rights Reserved.
Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers
Solutions
Whitepapers and eBooks
PDF: Security Reference Guide
PDF: Data and Identity Security
PDF: Secure Remote Access 101
Webcasts
User Experience Management Indicators for Business and IT Success
Ensuring Performance Meets Business and Web User Needs
3 of 3
9/11/15, 12:13 PM