Function arguments do not have to all be of the same type. It is perfectly reasonable to write a function that takes an integer, two longs, and a character as its arguments.

Any valid C++ expression can be a function argument, including constants, mathematical and logical expressions, and other functions that return a value. For example, if you have a function declared as

int MyFunction(int theIntegerParam, bool theBoolean);

you can legally invoke this function with any of the following function calls:

int z, x = 3, y = 5; // declare the variables z = MyFunction(x,y); // pass in an int and a bool variable z = MyFunction(32,true); // pass in two constants z = MyFunction(23+9, 100>5); // expressions which equate to 32, true ...

Start Free Trial

No credit card required