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?

Recommended Answers

All 3 Replies

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

void foo(int* prm1, int* prm2, int* prm3);

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.