Join Peggy Fisher for an in-depth discussion in this video Solution: Ask for a user's favorite movies, part of Up and Running with C++.
…Okay.…I hope you had luck with that last challenge,…writing a program to capture your three top favorite movies.…Here's one possible solution to the challenge.…For this solution, remember all classes contain two files.…The hetero file, in my case, movie.h.…And the class file, movie.cpp.…Let's start with the header file.…In the header file, I declared three private data variables.…I have a string for the movie name, an…integer for the year, and a string for the rating.…Next, in my header file, I list all the function prototypes for this class.…They're going to be public.…The first two are constructors.…I have a default constructor.…I have a constructor that takes three…parameters: a string, an int, and a string.…
I have my destructor.…And then I have access and mutator methods for each of the fields.…SetName, getName, setYear, getYear, set Rating, and getRating.…Remember, we don't actually define the functions in the header file.…That's done in the .cpp file.…Let's go take a look at the definition for these functions.…
- 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.