subject

We saw that it's common for an overloaded assignment operator in a class X to be declared with the return type X&. However, this turns out not be to an absolute requirement in C++; a program can compile with the return type being something different. Suppose that you wrote a class X with each of the following assignment operators declared. For each of them, briefly explain why making the specified design choice, rather than the usual one, would be problematic.
1. void operator=(const X& x)
2. X operator=(const X& x)
Answer these separately; in each case, only one of the assignment operators is declared, never both of them. Note that it wouldn't be an honest attempt to answer this question to say something like "Because C++ programmers usually declare an assignment operator as X& operator=(const X& x) instead." This question isn't asking what the usual design choices are; this question is about why.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 12:00
From excel to powerpoint, you can copy and paste a. cell ranges and charts, one at a time. b. cell ranges and charts, simultaneously. c. charts only. d. cell ranges only.
Answers: 3
question
Computers and Technology, 23.06.2019 16:00
Does read theory have answers keys ?
Answers: 1
question
Computers and Technology, 23.06.2019 20:30
If chris has a car liability insurance, what damage would he be covered for
Answers: 1
question
Computers and Technology, 25.06.2019 03:30
All nate specialties are offered at two levels, a. journeyman and master. b. installation and service. c. apprentice and journeyman. d. heating and air conditioning.
Answers: 1
You know the right answer?
We saw that it's common for an overloaded assignment operator in a class X to be declared with the r...
Questions
question
English, 08.05.2020 20:57
question
Biology, 08.05.2020 20:57
Questions on the website: 13722361