Jump to content
  • Advertisement
Sign in to follow this  
Angellore

Really Need Help With Pointers In C++.

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

Hi guys. Pointers in C++ have been a pain for me ever since I started learning it 2 years ago. I understand you can use them to pass variables by reference, and in that way modify the variable directly rather than passing a copy of them. Though there are two problems: * I haven't used C++ in a long time, so I forgot a bit about the whole reference thing. * I still have problems with their operators. So I was wondering if there are any books or tutorials I can read that are just dedicated to pointers. I will highly appreciate it!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Angellore
Hi guys. Pointers in C++ have been a pain for me ever since I started learning it 2 years ago. I understand you can use them to pass variables by reference

You would do that in C, but C++ has a better mechanism for that: references.

void pass_by_value(int x)
{
x = 10; // does not affect caller
}

void pass_by_reference(int& x)
{
x = 10; // does affect caller
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!