How do you create a function that takes user-defined parameters? For example, say I had a function:
I understand I can cout << Example (4,6); to add 4 to 6; however, how do I allow a user to define the parameters before the function is called, i.e., make their inputs the parameters of the function?Code:int Example(int x, int y){ answer = x+y; return answer; }
Is using a function that takes parameters defined by a user particularly useful in certain situations?
PS. I am not trying to build a calculator; I was just using the above code as an example.
Thanks.