![]() |
|
#1
|
||||
|
||||
Function returning pointer to itselfHello,
I was reading this famous C faq by steve summit where it was said that it is impossible for a function to return a pointer which points to a function of the same type. Mindboggling ? betcha!nonetheless it also suggested 'wrapping' a struct around such a function and then returning the struct would work here. So i tried with: CPP / C++ / C Code:
Code:
CPP / C++ / C Code:
Code:
CPP / C++ / C Code:
And the results are: Code:
I do not know how to use a typecast or a struct to create such a function. Input would be appreciated __________________
Hope to hear from you guys! -------------------------------------------------- Best Regards, Aijaz Baig. Last edited by aijazbaig1 : 10-Jul-2009 at 11:37.
Reason: adding more code
|
||||
|
#2
|
|||
|
|||
Re: function returning pointer to itselfQuote:
The thing about lists of Frequently Asked Questions is that they usually post some answers with a little insight thrown in: http://c-faq.com/decl/recurfuncp.html For examples of declarations and uses of function pointers in the same FAQ, see: http://c-faq.com/decl/pfitypedef.html and http://c-faq.com/ptrs/funccall.html Regards, Dave |
Recent GIDBlog
Problems with the Navy (Officers) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| run script command on ns2.26 | newbie06 | Computer Software Forum - Linux | 66 | 16-Jan-2010 10:53 |
| Problem executing nam-1.13 | RodolfoAlvizu | Computer Software Forum - Linux | 20 | 28-Feb-2009 15:23 |
| [Include] Doubly-linked List | dsmith | C Programming Language | 6 | 14-Apr-2006 13:12 |
| [Tutorial] Pointers in C (Part II) | Stack Overflow | C Programming Language | 0 | 27-Apr-2005 17:36 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The