Jump to content
  • Advertisement


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


references vs pointer

This topic is 5714 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

i have read examples of references and have seen that by using references the object which is taken by the function as argument doesnt call the constructor function which is good in terms of memory allocate/deallocate but whats the real differences between pointer/references...since references is an explicit poointer or something what is the exact definition of references anyway with regards SilentMonk

Share this post

Link to post
Share on other sites
You seem quite confused. Well, I think these are the main differences:

- must initially point to an existing object (but there''s nothing preventing you from taking a reference to an object, then deleting the object through a pointer, or returning a reference to a stack object)
- can''t be 0 (or NULL, however you like it)
- can''t use pointer arithmetic
- can''t be reassigned

Anyways, I think references are usually implemented as pointers, but it shouldn''t make any difference anywhere how they work.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!