quote:Original post by Village Specialton Many veterans will tell you thaqt pointers are the key to programming, but it seems languages that don''t use them get along just fine.
Every language uses pointers. A pointer is nothing but a reference to a location in memory. How they abstract these pointers to pretend they don''t exist is highly irrelevant.
quote: However, pointers are good for a few things. Using pointers, you can get the address of the function. This might be useful when your programming a giant game and need to keep track of a bot''s position. Pointers also allow you to waste memory to make your code look bigger. Anyways, I would say use them if you must. I see no point in the until you get into complex AI, but it is worth a try.
I really don''t want to comment on this remark. I''ll just quote it. This deserves to be quoted and perhaps even framed. I love gamedev.
quote:Original post by Ready4Dis They are pretty rare in C++, but I have a use for them still. In my GUI Objects, you can assign a function to call when the object is updated (or in a command buttons case, clicked). That way, the action will trigger the function to be called, then depending on what function you passed, it will perform whatever you want it to. There is no way around using function pointers with this, except for programming specific functions into the actual object code, which isn''t an option for anything that needs to be non-specific.
No, C++ style prefers using references/pointers to virtual classes for this.
Pass a keyword to execute and it will call the corresponding function.
edit : forgot a few const.
[edited by - Fruny on June 19, 2003 5:48:29 PM]
"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
"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
Pointers t functions are also used for accessing the newer features of OpenGL (the extensions). As you know, Windows only supports OpenGL 1.1. If you want to us any of the neat newer functions of OpenGL 1.4, you will need pointers-to-functions to access them.