Join Peggy Fisher for an in-depth discussion in this video Default arguments, part of Up and Running with C++.
…In the function header or the prototype, we've included…the data type of the argument in the parameters list.…It is also possible to set a…default value, for these arguments in the parameters…list that can be used to assign values,…when they are omitted from the function call.…In this program we will set up two default…values, for the length and width of a rectangle.…The default values are only used, when the…actual arguments are omitted from the function call.…In our function prototype, we have the return type of int, the name of the…function is findPerimeter, and the two variables…int length and int width, both have values.…
In the main part of our program.…We will call the function once with no arguments.…We will call it a second time with two arguments, and…finally we will call it one more time with only one argument.…At the bottom, is the actual definition of our function.…Int findPerimeter (int length, int width).…Return 2 times length plus 2 times width.…Let's see if we can predict, what the answer should be.…
- Downloading and exploring the C++ IDE
- Working with loops
- Using predefined functions
- Creating custom functions
- Creating and instantiating classes
- Working with external files
Skill Level Beginner
1. Getting Started
2. C++ Basics
3. Flow of Control
4. Classes and Objects
5. Data Structures
6. File Manipulation
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.