Join Peggy Fisher for an in-depth discussion in this video Creating user-defined functions, part of Up and Running with C++.
- View Offline
- Exercise Files
…IF function is a group of statements used to accomplish a specific task.…IF function definition includes these parts; it has a return type, it…has a function name, parameter list, and the body of the function.…Once we have the function defined, we need to call the function.…This is where some of the confusion can start.…But in our main program we call the…function using the name and providing any necessary parameters.…There is one type of function, a void function,…where there's no value being returned from the calling program.…
I think the best way to understand this is to take a look at a couple examples.…In this first program example, we have a user defined function…that calculates and returns the distance from one point to another.…This function needs the main program to send the x…and y points, and it returns a value representing the distance.…Let's walk through this program.…Notice we define the function above the int main.…That's because if we want to use it, init main, we…have to declare it first or, at least, declare a prototype.…
- 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.