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, 22.06.2019 16:10
When copying and pasting text, the first step is move your cursor type the text select the copy command select the paste command
Answers: 2
question
Computers and Technology, 22.06.2019 18:30
Which of the following commands is more recommended while creating a bot?
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
Why is an outfitting a workspace with video games in a technology development company considered a strategic use of money
Answers: 1
question
Computers and Technology, 24.06.2019 08:30
Aconsumer would pay an extra they used the rent to own program to buy the computer, rather than using cash. for all of the items, is the cheapest option over the life of the contract. the most expensive overall option is to use purchase the item.
Answers: 2
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
Mathematics, 22.06.2019 22:20
question
Mathematics, 22.06.2019 22:20
Questions on the website: 13722363