By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,233 Members | 1,880 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,233 IT Pros & Developers. It's quick & easy.

References

P: n/a
Hello,

I've seen almost everyone here talk about
references instead of pointers (as I understand it).
Anyone knows a good tutorial och can explain
the concept of references?

-- Pelle
Jul 23 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Pelle Beckman" <he******@chello.se> wrote in message
news:bbs6e.686$184.133@amstwist00
Hello,

I've seen almost everyone here talk about
references instead of pointers (as I understand it).
Anyone knows a good tutorial och can explain
the concept of references?

-- Pelle


You should be reading a good C++ textbook. Trying to pick up the language
from tutorials is a hopeless task. This book is freely downloadable (and
good):

http://mindview.net/Books/TICPP/ThinkingInCPP2e.html
--
John Carson

Jul 23 '05 #2

P: n/a
hi:
"More Effective C++" written by scott Meyers

sorry
Jul 23 '05 #3

P: n/a

"Pelle Beckman" <he******@chello.se> wrote in message
news:bbs6e.686$184.133@amstwist00...
Hello,

I've seen almost everyone here talk about
references instead of pointers (as I understand it).
Anyone knows a good tutorial och can explain
the concept of references?

You may also find the FAQ interesting. Not a tutorial, it may just answer
some of your questions on references:
http://www.parashift.com/c++-faq-lite/references.html

Regards,
Sumit.
--
Sumit Rajan <su*********@gmail.com>
Jul 23 '05 #4

P: n/a
I've seen almost everyone here talk about
references instead of pointers (as I understand it).
Anyone knows a good tutorial och can explain
the concept of references?


You can think of a reference as a pointer that cannot change where it is
pointing, but is used syntactically as if it were just a value.

Things to note:

1) Since passing by reference actually passes a pointer, any
modifications done in the function will affect the original value.
2) For large structs, passing by reference prevents you from having to
copy the data structure when passed.
3) If you don't need to do pointer fiddling, the syntax of references is
much easier than that of pointers.

Basically, a reference is a pointer with all of the "pointer-y" stuff
hidden from you.

Jon
----
Learn to program using Linux assembly language
http://www.cafeshops.com/bartlettpublish.8640017
Jul 23 '05 #5

P: n/a
Jonathan Bartlett wrote:
I've seen almost everyone here talk about
references instead of pointers (as I understand it).
Anyone knows a good tutorial och can explain
the concept of references?

You can think of a reference as a pointer that cannot change where it is
pointing, but is used syntactically as if it were just a value.

Things to note:

1) Since passing by reference actually passes a pointer, any
modifications done in the function will affect the original value.
2) For large structs, passing by reference prevents you from having to
copy the data structure when passed.
3) If you don't need to do pointer fiddling, the syntax of references is
much easier than that of pointers.

Basically, a reference is a pointer with all of the "pointer-y" stuff
hidden from you.

Jon
----
Learn to program using Linux assembly language
http://www.cafeshops.com/bartlettpublish.8640017


I find your description of references highly misleading. What you
describe is a const pointer, not a reference. A reference doesn't store
an address, it's just an alias for an object. That's all.

--
Matthias Kaeppler
Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.