Skip to main content
gamedev.net
🔒 Locked

function pointers

Started by iGore Jun 17, 2002 at 5:48 PM 9 replies 1.2k views
Original Post
iGore
iGore
I''m curious, am I the only one who finds function pointers incredibly useful, but hates them for their implementation difficulties?
-iGore-
Fruny
Fruny
I like function pointers.
I don''t find them difficult to use.
What do you find wrong with them ?

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
IndirectX
IndirectX
/me agrees with Fruny.
---visit #directxdev on afternet <- not just for directx, despite the name
Spartacus
Spartacus
Function pointers are useful but I don''t use them much though. If you are using C++, you can in many cases use virtual functions instead. For that reason I only use function pointers for callback functions.

Spartacus
Real programmers don't document, if it was hard to write it should be hard to understand
GarlandIX
GarlandIX
That''s no problem, simply go to www.function-pointer.org to find out more than you ever want to know about function pointers.

------------------------------
BASIC programmers don''t die, they just GOSUB and don''t return.
------------------------------BASIC programmers don't die, they just GOSUB and don't return.
DrPizza
DrPizza
The only annoyance I have with them is that you can''t treat a bound member function pointer as a regular function pointer (though I think g++ has an extension to permit this), and you can''t elegantly frig it with a class or classes.

char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;} /*** drpizza@battleaxe.net ***/
Fruny
Fruny
quote:
Original post by DrPizza
The only annoyance I have with them is that you can''t treat a bound member function pointer as a regular function pointer (though I think g++ has an extension to permit this), and you can''t elegantly frig it with a class or classes.



That''s what boost::function has been created for.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
iGore
iGore
boost:: ?? What is that?

I would be very nice to have a class hold a function pointer to one of it''s own classes. I''m sure that there are ways to do this, but I would like a way that doesn''t require a C++ genious to write. All the function pointers that I''ve had to use, to get my task done, I''ve had to make global.
-iGore-
IndirectX
IndirectX
Boost.
---visit #directxdev on afternet <- not just for directx, despite the name

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.