Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

return (0): 1. GetFlix Video uses classes and objects to keep track of their mov

ID: 3724093 • Letter: R

Question



return (0): 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 (charchar int -0); char* get name O freturn name; char get tapeid 0treturn id) void check out (int num) number on hand num void return movie int num)number on handnm: void printo: private: char name char id: int number on hand Write the constructor for class Video. Keep in mind that the number on hand should never be a negative number!! a. b. If the method for function print were defined as follows: void Video:printo cout

Explanation / Answer

1

a.

public:
Video(char *name ="",char *id="",int number_on_hand=0) // Constructor definition
{
this->name = name;
this->id = id;
if(number_on_hand >= 0)
this->number_on_hand = number_on_hand;
}

b

Fargo
F455
15
The Big Stuff
S123
0
Fargo
F455
12

c. The compiler gives an error message if we include the statement cout<<movie.name;. This is because name is the private variable declared inside the class. We cannot access it outside the class in main.

2

a 10 ( ptrx is assigned the base address of array x and the value at base address is 10)

b 30 (two elements after base address)

c 10 (value at base address)

d 12 (*x +2 = 10+2)

e 30 (*(x+2) = *(3rd element in x))

f address of x[4] (fourth element in array x = ptrx+3)

g 50 ( array index starts from 0)

h

for(i=0;i<8;i++)

cout<<*(x+i); or cout<<*ptrx++;

3

a. ptrstuff = new char[n];

b. delete ptrstuff;