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: vectorchoices; } 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
shared_ptr
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?
templatevoid 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
Any of these is OK
output(cout, ilist, 4);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started