Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 2nd, 2004, 8:57 AM   #11
gamesage
Programmer
 
Join Date: Sep 2004
Location: Clemson, SC
Posts: 35
Rep Power: 0 gamesage is on a distinguished road
Send a message via AIM to gamesage
Okay, this may be a stupid question, but what advantages do pointers have over references? I'm reading Learn C++ in 21 Days and, from what I've seen so far, reference syntax is much easier than pointer syntax. Sorry if its a stupid question, I haven't gotten to the really advanced topics yet.
__________________
Free Porn!!
gamesage is offline   Reply With Quote
Old Oct 2nd, 2004, 10:37 AM   #12
Ravilj
Programmer
 
Ravilj's Avatar
 
Join Date: Sep 2004
Location: JHB , South Africa
Posts: 79
Rep Power: 5 Ravilj is on a distinguished road
Quote:
Originally posted by Myself (to lazy to retype it)

References are used mainly for passing large structures to functions. When passing data to functions you have 2 options:
1. Pass by value
This passes a new instance of the variable to the function.
2. Pass by reference
This passes the address of the varaible to the function.

Passing by reference is more efficient as well as it still allows you to use the variables name with out having to worry about dereferencing it. References also allow you to change the data of the variable passed without having to return it. This can be a good thing and a bad thing so 'const' is often used in conjunction with references.

References are choosen above pointers for this reason since they are easier to use. Pointers are gernerally left for dynamically allocating memory and such and referencing dynamic objects.
References vs. Pointers
__________________
Ravilj's OpenGL Terrain aka WinTerrain Last Updated: 17/01/2005!
Ravilj is offline   Reply With Quote
Old Oct 2nd, 2004, 12:16 PM   #13
Benoit
Expert Programmer
 
Benoit's Avatar
 
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 556
Rep Power: 5 Benoit is on a distinguished road
All this programming stuff gets confusing :blink:
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4
Benoit is offline   Reply With Quote
Old Oct 2nd, 2004, 2:24 PM   #14
gamesage
Programmer
 
Join Date: Sep 2004
Location: Clemson, SC
Posts: 35
Rep Power: 0 gamesage is on a distinguished road
Send a message via AIM to gamesage
Thanks, Ravilj. I actually looked in the C++ section for a topic like this before I posted. I guess I'm just blind. :blink: :ph34r:
__________________
Free Porn!!
gamesage is offline   Reply With Quote
Old Oct 2nd, 2004, 2:26 PM   #15
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
No! Programming is the greatest thing in the world, except maybe basketball. God I'm a nerd.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Oct 2nd, 2004, 2:50 PM   #16
Benoit
Expert Programmer
 
Benoit's Avatar
 
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 556
Rep Power: 5 Benoit is on a distinguished road
Yes programming is the best thing in the world...So logical
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4
Benoit is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:18 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC