• Advertisement
Sign in to follow this  

Pointers

This topic is 4253 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Guest Anonymous Poster
-loop iteration
-dynamic memory allocation
-function pointers
-dividing a datam into smaller parts witbout moving its bits around

Share this post


Link to post
Share on other sites
Sorry... don't quite understand your question.

Pointers in C++ are alot like pointers in other languages. Pointers *point* (no pun intended) to a location in memory. It is like a handle (my own term, not the C++/CLI handle) that allows you to manipulate that piece of memory.

Some common uses of pointers:

1) manipulating values/objects
Instead of passing around by value that can get pretty inefficient in terms of the value/object copying, you pass around the pointer to that value/object. You can then manipulate that value/object via its pointer using "->" operator.

2) manipulating functions
Using function pointers (i.e.: pointers that point to functions of specific prototype), you can actually get your program to call functions during runtime, whose specific names are not known at compile time. A related use is also to implement function callbacks (i.e.: basically a mechanism by which a function can "callback" the function that called it in the 1st place).

3) manipulating arrays
This is actually similiar to point (1) above. Instead of passing around and manipulating the actual array elements, you pass around and manipulate them via the array pointer.

There are other great uses for pointers.

Hope that was useful to you.

Have fun! :)

Joshua

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement