• Advertisement

Archived

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

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

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