1. Home
  2. Computer Science MCQs
  3. C++ and Object-Oriented Programming
  4. In C++11, declaring a user-defined destructor, copy…

Added 30 Nov -0001

In C++11, declaring a user-defined destructor, copy constructor or copy assignment operator suppresses which implicitly generated members?

  1. Nothing; all special members are still generated normally
  2. The move constructor and move assignment operator Correct answer
  3. The default constructor and the copy constructor
  4. Only the destructor, which must then be defined by the user

Correct answer

B. The move constructor and move assignment operator

14 views

MCQSEXAM

Explanation

Rule of five: declaring any of the destructor, copy constructor or copy assignment operator prevents generation of the move constructor and move assignment operator, so copies silently take over and performance degrades. Such types stay copyable but not movable unless the moves are explicitly defaulted. Types that manage resources should therefore declare all five members deliberately.

Reference

Asked in: NTS, PPSC IT, Campus Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More C++ and Object-Oriented Programming MCQs

Practise all C++ and Object-Oriented Programming MCQs

Similar MCQs