Course Web Pages

Related Links

Free eBooks


Special Functions

The videos below explain how to write functions with default arguments, overloaded functions, and inline functions. The examples are taken from Beginning C++ Through Game Programming, by Michael Dawson.

Creating and using default arguments

 give_me_a_number.cpp


Overloaded functions

 taking_damage.cpp


Inline functions

 triple.cpp


MadLib

 mad-lib.cpp


Exercise

Write a program with two overloaded functions named multiply. The function prototypes for the functions should look like this:

      int multiply(int multiplier, int number);
      string multiply(int multiplier, string text);
      

The first function should output the product of its two inputs. The second function should output the string text concatenated with itself multiplier times. Refer to triple.cpp if you need help getting started.