Jump to content
  • Advertisement

Archived

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

johnnyBravo

How to make a method change a variable(an int) outside of itself?

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

say i got a method called Addition. Where the first thing u enter is the "Output of the answer", the second is the first number, and the third is the second number to be added. i want to have the first thing entered eg an int answer; to be filled with the answer..

Share this post


Link to post
Share on other sites
Advertisement
You pass the argument by reference, rather than by value. Look up "references" in your C++ book.


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Or use a pointer. In this case, using a reference is probably more appropriate, but you should still know how to use pointers.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!