O'Reilly logo

Sams Teach Yourself C++ in 24 Hours, Third Edition by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Function Arguments

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required