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?

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