Array with pointer

Reply

Join Date: Sep 2008
Posts: 40
Reputation: cutedipti is an unknown quantity at this point 
Solved Threads: 0
cutedipti cutedipti is offline Offline
Light Poster

Array with pointer

 
0
  #1
Oct 14th, 2008
Hellow.......!
I need a help for: How will you declare an array of three function pointers where each function receives two integers and returns a float?
Thanks & Regards
Ms. Dipti
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 206
Reputation: grumpier has a spectacular aura about grumpier has a spectacular aura about 
Solved Threads: 31
grumpier grumpier is offline Offline
Posting Whiz in Training

Re: Array with pointer

 
0
  #2
Oct 14th, 2008
The simpler way (less error prone) is to use a typedef helper.
  1. typedef float ((*YourFunction)(int, int);
  2. YourFunction YourArray[3];
or, if you wish code that is terse but easier to get wrong (typos very easy), use this;
  1. float (*YourArrayAlternative[3])(int, int);
to declare an array named YourArrayAlternative.

Whichever way you choose to do it, I'll leave it to you to work out how to initialise array elements.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC