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

The next few questions deal with the class definition (.h file) shown below. The

ID: 640005 • Letter: T

Question

The next few questions deal with the class definition (.h file) shown below. The class Blockbuster represents a popular Hollywood movie.

#include <string>
using namespace std;
namespace cs52 {

class Blockbuster{
public:

Blockbuster( int length, string title, string star );

friend bool equal( const Blockbuster & b1, const Blockbuster & b2 );
int getLength();
string getTitle();
string getPlace();

void setTitle( string title );
void setPlace( string place );
void setLength( int length );

private:

int my_Length; // feature length in minutes
string my_Title; // feature title
string my_Star; // leading actor or actress

};

}

Which of the following statements is a valid way to create a Blockbuster object?

Select one:

a. std::Blockbuster b( 100, "Rambo" );

b. std::Blockbuster b( 100, "Rambo", "Sylvester Stallone" );

c. cs52::Blockbuster b;

d. cs52::Blockbuster b( 100, "Rambo", "Sylvester Stallone" );

Which of the following parts of your program have access to the member variable my_Title directly without calling a method?

Select one:

a. Driver code like void main() {...}

b. Only methods within the class Blockbuster itself

c. Methods within classes other than Blockbuster

d. All of the above choices have access to the variable my_Title directly without calling a method

Based on the Blockbuster class shown above, can the friend function equal() be marked const?

Select one:

a. Not enough information has been provided to answer this question

b. No

c. It depends on exactly what the method equal does

d. Yes

Sally the Programmer intends to write a method body of the getter method:

string Blockbuster::getTitle( )

Which of the following would be the correct implementation?

Select one:

a. return( my_Title );

b. title = my_Title;

c. myTitle( );

d. my_Title = title;

Suppose you decide to overload the == operator in the class Blockbuster. What is the valid function declaration for the operator == that belongs in the class implementation (.cpp) file shown above?

Select one:

a. operator ==(const Blockbuster & b1, const Blockbuster & b2)

b. bool operator ==(const Blockbuster & b1 )

c. bool operator Blockbuster::==(const Blockbuster & b1, const Blockbuster & b2)

d. bool operator ==(const Blockbuster & b1, const Blockbuster & b2)

Explanation / Answer

Q: Which of the following statements is a valid way to create a Blockbuster object?

Ans: d. cs52::Blockbuster b( 100, "Rambo", "Sylvester Stallone" );

namespace followed by class name then object name then set of parenthesis

Q: Which of the following parts of your program have access to the member variable my_Title directly without calling a method?

Ans: b. Only methods within the class Blockbuster itself

because private members can only be accessed by the member functions of the respective class.

Q: Based on the Blockbuster class shown above, can the friend function equal() be marked const?

Ans: d. Yes

Q: Sally the Programmer intends to write a method body of the getter method:

string Blockbuster::getTitle( ). Which of the following would be the correct implementation?

Ans: d. my_Title = title;

Q: Suppose you decide to overload the == operator in the class Blockbuster. What is the valid function declaration for the operator == that belongs in the class implementation (.cpp) file shown above?

A: d. bool operator ==(const Blockbuster & b1, const Blockbuster & b2)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote