I found this exercise about C++ in a list and just couldn’t solve it. Here it is:
Let’s say we have the following instruction:
ObjA = ObjB;
In which ObjA is an object of ClassA, and ObjB is an object of ClassB, this will run properly, if and only if there is:
A. A conversion function in ClassA
B. A conversion function in ClassB
C. A constructor in ClassA
D. A constructor in ClassB
There can be multiple correct answers.
My problem with this exercise is that they are both objects, and, theoretically, you can’t change the instance inside an object – and that is what I think the ‘=’ would do there. Since there can be multiple correct answers, I thought, therefore, that none were correct. But I’m not sure.
This will run correctly if any of these is true:
ClassAwhich takes an argument of typeClassBClassAwhich takes an argument of typeXand there is conversion function to typeXinClassB.ClassAinClassB.I don’t know how/if these match to the ABCD choice(s) you have.