Pointers

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2009
Posts: 28
Reputation: Your_mum is an unknown quantity at this point 
Solved Threads: 0
Your_mum Your_mum is offline Offline
Light Poster

Pointers

 
0
  #1
Oct 23rd, 2009
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???
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,678
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 263
Lerner Lerner is offline Offline
Posting Virtuoso
 
0
  #2
Oct 23rd, 2009
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.
Klatu Barada Nikto
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 28
Reputation: Your_mum is an unknown quantity at this point 
Solved Threads: 0
Your_mum Your_mum is offline Offline
Light Poster
 
0
  #3
Oct 23rd, 2009
Thnx..
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC