943,969 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 260
  • C++ RSS
Oct 23rd, 2009
0

Pointers

Expand Post »
Had a look at pointers in the tut I am following, and I can't really get my head around why their useful. It says they are, but tells you no more???
Reputation Points: 10
Solved Threads: 0
Light Poster
Your_mum is offline Offline
30 posts
since Jun 2009
Oct 23rd, 2009
0
Re: Pointers
Pointers are useful for a variety of reasons. For, example, let's say I want to pass the value of my salary from one function to another. The value of my salary will be changed in the function it is passed to and I want to use that new value in a third function. Pointers are one way that allow the change in a variables value in one function to be retained in the calling function. Or let's say I have a collection of appointments that are used in several different places and I want to be able to arrange it so that if I change something in one appointment that change is reflected wherever that appointment might be used. Pointers allow that to happen. Or let's say that I want to use more variables than the compiler stack will allow. I might be able to go into preferences and change the size of the compiler stack, but by using pointers I can access memory outside the compiler stack using dynamic memory. Or let's say I have a group of objects all derived from the same base class and I want to be able to call a single function and get the action of the specific derived class by using the same function call. Pointers allow that to happen to. There are probably other examples as well, and some of my examples may not be the most clear. Suffice it to say that learning how pointers work is an integral part of writing code in some languages, so take a deep breath, count to 10, and jump in.
Reputation Points: 718
Solved Threads: 373
Nearly a Posting Maven
Lerner is offline Offline
2,253 posts
since Jul 2005
Oct 23rd, 2009
0
Re: Pointers
Thnx..
Reputation Points: 10
Solved Threads: 0
Light Poster
Your_mum is offline Offline
30 posts
since Jun 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: help plz
Next Thread in C++ Forum Timeline: c++ used for games





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC