Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Neo4j

Authors: Gregory Jordan

1st Edition

1484200225, 9781484200223

More Books

Students also viewed these Databases questions

Question

Understand why customers are loyal to a particular service firm.

Answered: 1 week ago