As the saga Continues
As my never ender sage to learn C++ continues I must ask, why would you ever need a pointer to a pointer?
"The most likely way for the world to be destroyed, most experts agree, is by accident. That''s where we come in; we''re computer professionals. We cause accidents."
-Nathaniel Borenstein
To pass the pointer to a function, and have the function change the address the pointer is pointing to.
The world holds two classes of men -- intelligent men without religion, and religious men without intelligence. Abu''l-Ala-Al-Ma''arri (973-1057; Syrian poet)
The world holds two classes of men -- intelligent men without religion, and religious men without intelligence. Abu''l-Ala-Al-Ma''arri (973-1057; Syrian poet)
The simple answer is "you hardly ever need a pointer to a pointer". I can''t remember the last time I needed this in C++. If you can''t think of why you would need one, then you probably don''t need one. Most uses of pointers in C++ should be replaced with strings, vectors, smart pointers, handle classes, etc.
You need a lot of pointers to pointers for the DirectX API, but for my own routines i don''t use them.
You really won''t need pointers until later in your "saga" when you learn a graphics/sound/input API. Right now, just read as much about them as you can so you understand them as well as possible. Once you start to need them, read about them again, and you''ll find a use for them if need be.
As of now, I''ve coded a bunch of small games and I haven''t used any pointers, other than ones that were needed to use my API.
Good luck!
------------------------------
Simple DirectMedia Layer:
Main Site - (www.libsdl.org)
Cone3D Tutorials- (cone3D.gamedev.net)
GameDev.net''s Tutorials - (Here)
OpenGL:
Main Site - (www.opengl.org)
NeHe Tutorials - (nehe.gamedev.net)
Online Books - (Red Book) (Blue Book)
As of now, I''ve coded a bunch of small games and I haven''t used any pointers, other than ones that were needed to use my API.
Good luck!
------------------------------
Simple DirectMedia Layer:
Main Site - (www.libsdl.org)
Cone3D Tutorials- (cone3D.gamedev.net)
GameDev.net''s Tutorials - (Here)
OpenGL:
Main Site - (www.opengl.org)
NeHe Tutorials - (nehe.gamedev.net)
Online Books - (Red Book) (Blue Book)
quote:Original post by SabreMan
The simple answer is "you hardly ever need a pointer to a pointer". I can''t remember the last time I needed this in C++. If you can''t think of why you would need one, then you probably don''t need one. Most uses of pointers in C++ should be replaced with strings, vectors, smart pointers, handle classes, etc.
I''m genuinely surprised at this claim. Pointers to pointers are used extensively in many many APIs. Generally, containers should be used to store pointers to objects instead of objects themselves (because copying pointers is faster than copy c-tors).
Whilst you might not create the pointers to pointers yourself, that doesn''t obviate their need.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement