Question: 45. What is wrong with the following String class member function definition to copy the other String to this one? String::String(const String& other) { buffer

45. What is wrong with the following String class member function definition to copy the other String to this one?

String::String(const String& other) { buffer = other.buffer; len = other.len; }

Group of answer choices

The argument inside the parentheses should not be declared const

It would lead to data conflicts as modifications to the new object would also modify the other one

It would lead to memory leaks, as deleting the other object would not delete the new one

It does not copy all the required data

46. Which of the following is a correct declaration of operator=?

Group of answer choices

String& operator=(String& left, const String& other)

String& String::operator=(const String& other) const

String& String::operator=(String& other)

void String::operator=(const String& other)

47. Which line of code will best complete this function from the textbook example Question base class?

class Question { public: Question(); Question(const string& s); . . . _____________________________//line of code goes here private: string text; string answer; }; class ChoiceQuestion : public Question { . . . private: vector choices; } Question::~Question() {} ChoiceQuestion::~ChoiceQuestion() { //code for this not shown}

Group of answer choices

operator=(Question& other);

virtual ~Question();

~Question();

None of these

48. Which statement best describes this function from the textbook example String class?

String::String(String&& other) { len = other.len; buffer = other.buffer; other.buffer = nullptr; }

Group of answer choices

String&& denotes a reference to a temporary object that will be destroyed after the call.

It is a virtual constructor.

String&& is a syntax error and should be String&.

It is a copy constructor.

49. Which of the following provides automated memory management and frees up memory when the Question object is no longer required?

Group of answer choices

vector q1(1);

shared_ptr q1(new Question);

Both A and B

Question* q1 = new Question;

50. Which of the following is the proper useage of the output() function below with the given arrays?

template void output(ostream& out, T data[], int size) { for (int i = 0; i < size; i++) { if (i > 0) { out << ", "; } out << data[i]; } out << endl; } double mylist[] = {1,2,3,4.5}; int ilist[] = {1,2,3,4};

Group of answer choices

output(cout, mylist, 4);

output(cout, mylist, 4);

Any of these is OK

output(cout, ilist, 4);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!