Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

41. What is the term for the function in a C++ class definition that can de-allocate dynamic memory when the object goes out of scope,

41.What is the term for the function in a C++ class definition that can de-allocate dynamic memory when the object goes out of scope, as in a return from a function which has created a local object?

Group of answer choices

Tilde function

Exit

Deconstructor

Destructor

42. Why do we need to overload the assignment operator in some class interfaces, such as in String& String::operator=(const String& other)?

Group of answer choices

To copy buffers used by both the object on the left and the object on the right side of the equals

To delete (free) unused memory pointed to by the object

All of these

To prevent memory leaks

43. Which line(s) of code will complete this function from the textbook example String class?

String& String::operator=(const String& other) { if (this != &other) { delete[] buffer; len = other.len; if (len > 0) { buffer = new char[len]; for (int i = 0; i < len; i++) { buffer[i] = other.buffer[i]; } } else { buffer = nullptr; } } _____________________________//line(s) of code go(es) here }

Group of answer choices

return buffer;

return *this;

delete[] buffer;

All of these

44. Which of the following is the proper function prototype for the String class copy-constructor?

Group of answer choices

String::String(const String& other)

String::String()

String::String(String this, const String& other)

String::String=(const String& other)

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

Data Management Databases And Organizations

Authors: Richard T. Watson

2nd Edition

0471180742, 978-0471180746

More Books

Students also viewed these Databases questions