c pointer declarations
DESCRIPTION
function pointersTRANSCRIPT
-
Partners & AffiliatesData Centers DataCentersprepaid calling cardprepaid calling cardRun Cloud Apps RunCloud AppsLean App Platform LeanApp PlatformPhone Cards PhoneCardsDesktop ComputersDesktop ComputersBusiness Email BusinessEmailIT Legal Contracts ITLegal ContractsData Center Data CenterPDA Phones & CasesPDA Phones & CasesCell Phones Cell PhonesCar Donations CarDonationsDedicated ServersDedicated ServersLiability Insurance LiabilityInsurance Reply to this comment
Not sure if you have an account?
Include Code Search Tips
TODAY'S HEADLINES | ARTICLE ARCHIVE | SKILLBUILDING | TIP BANK | SOURCEBANK | FORUMS | NEWSLETTERS
Specialized Dev Zones
Vendor Solutions
eBook Library NEW
Webcasts
.NET
Java
C++
Web Dev
Architecture
Database
Security
Open Source
XML
Semantic Web
VB Classic
ASP/ASP.NET
Enterprise
Mobile
Special Reports
10-Minute Solutions
DevXtra Editors' Blog
Shop DevX
APIfinder
Google Site Search
Help site visitors findthe right information
quickly.
Google Site Search
Average Rating: 4.4/5 | Rate this item | 111 users have rated this item.
Expertise: AdvancedLanguage: C++
March 8, 2000
Hide Function Pointer Declarations With a typedef
Can you tell what the following declaration means?
void (*p[10]) (void (*)() );
Only few programmers can tell that p is an "array of 10 pointers to a function returning void and taking apointer to another function that returns void and takes no arguments." The cumbersome syntax is nearlyindecipherable. However, you can simplify it considerably by using typedef declarations. First, declare atypedef for "pointer to a function returning void and taking no arguments" as follows:
typedef void (*pfv)();
Next, declare another typedef for "pointer to a function returning void and taking a pfv" based on thetypedef we previously declared:
typedef void (*pf_taking_pfv) (pfv);
Now that we have created the pf_taking_pfv typedef as a synonym for the unwieldy "pointer to a functionreturning 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 tipsubmission. You must accumulate 10 acceptable tips to receive payment. Be sure to include a clear explanation of what thetechnique does and why it's useful. If it includes code, limit it to 20 lines if possible. Submit your tip here.
DevX: C++ Zone Browse "C++" Tips Browse All Tips
Please rate this item (5=best)
1 2 3 4 5
By raviparu December 8 2009 2:17 AM PDT
This example really helps in simplifying any sort of complex function pointer declarations
Add a commentEnter a username
Email address (used only for verification; it will not be displayed or added to any list)
Please type the alphanumeric characters above. What's this?
IT Professionals Developers Solutions eBook Library Webopedia Login Register
Hide Function Pointer Declarations With a typedef file:///Users/saumitre/other/read/tech/c-func-ptrs-typedef.htm
1 of 3 9/11/15, 12:13 PM
-
Reply to this comment
Help site visitors findthe right information
quickly.
I cannot read this. Please generate a New image
Your comment:
(Maximum characters: 1200). You have 1200 characters left. HTML characters will not be displayed.
I agree to the Terms of Use
Need help?
Acceptable Use Policy
By raviparu December 8 2009 2:17 AM PDT
This example really helps in simplifying any sort of complex function pointer declarations
Add a commentEnter a username
Email address (used only for verification; it will not be displayed or added to any list)
Please type the alphanumeric characters above. What's this?
I cannot read this. Please generate a New image
Your comment:
(Maximum characters: 1200). You have 1200 characters left. HTML characters will not be displayed.
I agree to the Terms of Use
Need help?
Acceptable Use Policy
World's Fastest Object Database. World's Fastest Object Database.
Intel Parallel Studio helps C++ developers find latent memory errors thatcause crashes and lockups Intel Parallel Studio helps C++ developers findlatent memory errors that cause crashes and lockups
Intel Parallel Studio helps C++ developers add parallelism to apps to takeadvantage of multicore. Intel Parallel Studio helps C++ developers addparallelism to apps to take advantage of multicore.
Intel Atom Developer Windows Beta 3 SDK Brings Enhancements & ComponentIntegration Intel Atom Developer Windows Beta 3 SDK Brings Enhancements& Component Integration
C++ developers use Intel Parallel Studio to locate and optimize hotspots andboost performance. C++ developers use Intel Parallel Studio to locate andoptimize hotspots and boost performance.
Hide Function Pointer Declarations With a typedef file:///Users/saumitre/other/read/tech/c-func-ptrs-typedef.htm
2 of 3 9/11/15, 12:13 PM
-
Advertising Info | Permissions | Help | Site Map | Network Map | About
The Network for Technology Professionals
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
SolutionsWhitepapers and eBooksPDF: Security Reference GuidePDF: Data and Identity SecurityPDF: Secure Remote Access 101
Helpful Cloud Computing ResourcesMORE WHITEPAPERS, EBOOKS, AND ARTICLES
WebcastsUser Experience Management Indicators for Business and IT SuccessEnsuring Performance Meets Business and Web User Needs
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKitsIBM DB2 e-kit for Database Professionals: Extending Skills is Fast and EasyGet BlackBerry Enterprise Server Express for Free
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and DemosDemo: Google Site SearchVirtual Event: Master Essential Techniques for Leveraging the CloudArticle: Explore Application Lifecycle Management Tools in Visual Studio 2010Internet.com Hot List: Get the Inside Scoop on IT and Developer Products
New Security Solutions Using Intel(R) vPro(TM) TechnologyAll About BotnetsMORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES
Hide Function Pointer Declarations With a typedef file:///Users/saumitre/other/read/tech/c-func-ptrs-typedef.htm
3 of 3 9/11/15, 12:13 PM