confusion

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

Join Date: Jul 2008
Posts: 111
Reputation: clutchkiller is an unknown quantity at this point 
Solved Threads: 1
clutchkiller's Avatar
clutchkiller clutchkiller is offline Offline
Junior Poster

confusion

 
0
  #1
Dec 11th, 2008
My biggest problem right now in understanding c++ is pointers.

Im curious to its specific funcionality, so instead of doing somthing like
p = &x
then calling x using *p, why couldn't you just say x = p?

Im pretty sure my syntax is wrong, but hopefully i'm getting my question across properly. Thanks!
>That confuses me =(
Get used to it. Good programmers are in a constant state of confusion.
>Looks like i have some quasi specifics to investigate! Up Up And AWAY!
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 118
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

Re: confusion

 
0
  #2
Dec 11th, 2008
pointers are just like ordinary variables that carry the address of other variables and objects. you need pointers because sometimes when passing information within your program, let say from a function to a function, you dont want to pass all the data, instead you want to pass the address of that data in memory, that is when pointers become useful. they are also used for memory management as they are able to address to memory.
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 118
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

Re: confusion

 
0
  #3
Dec 11th, 2008
i have an apple analogy for you, if you ask for an apple, i can bring it to you, or i can say that it is in the kitchen and you can go and grab it. i am not a good c++ programmer though, but it is easy to understand things when some one is as bad as you
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 90
Reputation: unbeatable0 is an unknown quantity at this point 
Solved Threads: 12
unbeatable0 unbeatable0 is offline Offline
Junior Poster in Training

Re: confusion

 
0
  #4
Dec 12th, 2008
I also had a big problem understanding pointers, but it's not that hard:
pointers are just like any other variables when you use the asterisk (*) before them - which leads to the value in the address they hold.
They're useful because, just how serkansendur said, you can save computer memory when passing them to functions (because you send the whole address and not a copy of the variable), and you can manage the variables' values throught them.
Passing an address to a pointer in a function is similar to sending a reference (with the prefix &) to a function, except that a reference can't get a new address to refer to.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: confusion

 
0
  #5
Dec 12th, 2008
Look at the excellent tutorial by Julienne Walker:
http://eternallyconfuzzled.com/tuts/..._pointers.aspx
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC