954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Quick question, call by reference?

One of the questions for my study guide asks to write a function that prompts the user to enter 3 integers, then "return" the integers via it's parameters through call by reference. Does this just imply using pointers as arguments, then when the values are changed in the function they are also changed in main? What would the function prototype look like if it's not that way?

Savage221
Newbie Poster
20 posts since Oct 2005
Reputation Points: 10
Solved Threads: 0
 

yes, I think you have the right idea. The prototype might look something like this:

void foo(int* prm1, int* prm2, int* prm3);
Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Or in case you've by mistake posted this in C instead of C++ the prototype of interest would be

void foo(int& prm1, int& prm2, int& prm3);
thekashyap
Practically a Posting Shark
811 posts since Feb 2007
Reputation Points: 254
Solved Threads: 75
 

Meant for it to be C, but thank you very much for looking out :) Thanks Ancient Dragon and thekayshyap, much appreciated!

Savage221
Newbie Poster
20 posts since Oct 2005
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You