Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

cow_in_the_well

& and * and all that jazz

This topic is 6545 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
void foo(int *number); recieves a pointer to an integer, while the other one recieves a reference to it. A pointer is holds the address of a variable, while a reference is an alias for the variable name. There is not much noticable diff. but they are diff.

*** Triality ***

Share this post


Link to post
Share on other sites
an important diff is that you cant really pass null to a reference so you dont have to check that it is a valid pointer.


JS
http://www.thepeel.com/void

Share this post


Link to post
Share on other sites
quote:
Original post by JS

an important diff is that you cant really pass null to a reference so you dont have to check that it is a valid pointer.


No, you can - and very easy:

foo( *(int*) NULL );

You just don''t have to worry about it in the function.

Share this post


Link to post
Share on other sites
The first is C''s way of manually constructing a call by reference, using a pointer. That is, when you call this function you will pass an address.

The second is C++''s reference parameter operator, you can call it without using any operator and can access it in the function without needing special operators, it will automatically obtain the address for you.

I''m not sure that is totally correct, but I think the idea is right.
I''m sure I''ll be corrected if null_pointer comes along

-Mezz

Share this post


Link to post
Share on other sites
Yep!
Those guys are perfectly right.
If you still don''t understand it, you should read a book about c++ (stroustroups if you''re a hard one), or alternatively search through the forums here; it was explained *soooo* many times...

pi~

*jazz... mmm... i like jazz...*

Share this post


Link to post
Share on other sites
Serge K, could you check out My Question and give me a few guidelines, since you seem to know that stuff pretty good! Thank you!

-------------------------------
That's just my 200 bucks' worth!

..-=gLaDiAtOr=-..

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!