Q. Which of the following is the correct way to define a copy assignment operator in C++?

  • (A) MyClass& operator=(const MyClass& other) { }
  • (B) MyClass& operator=(MyClass& other) { }
  • (C) Both A and B
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (A) MyClass& operator=(const MyClass& other) { }
Explanation: The correct way to define a copy assignment operator is 'MyClass& operator=(const MyClass& other) { }'.
Explanation by: Gopal Sharma
The correct way to define a copy assignment operator is 'MyClass& operator=(const MyClass& other) { }'.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
126
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Gopal Sharma
Publisher
πŸ“ˆ
92%
Success Rate