Question
1. GetFlix Video uses classes and objects to keep track of their movie rentals. Below is the class definition for a Video class. class Video{
1. GetFlix Video uses classes and objects to keep track of their movie rentals. Below is the class definition for a Video class.
class Video{
public:
Video (char* = "", char* = "", int = 0); char* get_name () {return name;} char* get_tapeid (){return id;} void check_out (int num) {number_on_hand -= num;} void return_movie (int num){number_on_hand += num;} void print();
private: char* name;
char* id; int number_on_hand;
};
a. Write the constructor for class Video. Keep in mind that the number_on_hand should never be a negative number!!
b. If the method for function print were defined as follows:.
void Video::print() {
cout << name << endl; cout << id << endl; cout << number_on_hand << endl;
} What would be printed from the following C++ program?
#include
int main() {
Video movie ("Fargo", "F455", 15); Video movie2("The Big Stuff", "S123"); movie.print(); movie2.print(); movie.check_out(3);
movie.print();
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started