1.1 Which of the following overloaded assignment operators should be used if our
ID: 3706933 • Letter: 1
Question
1.1 Which of the following overloaded assignment operators should be used if our intention is to place the two Robots into separate collections, while still referring to the same single logical Robot in the simulation?
a.
b.
c.
d. friend Robot& operator=(const Robot& lhs, const Robot& rhs) {
1.2 Which of the following overloaded equivalence operator definitions should be used if our intention is that the Robots are equal if they occupy the exact same location in memory?
a. bool operator==(const Robot& rhs) { return (this == &rhs); }
b. bool operator==(const Robot& rhs) { return ((arena_ == rhs.arena_) && (radius_ == rhs.radius_) && (sensor_->get_active() == rhs.sensor_->get_active()));} };
c. friend bool operator==(const Robot& rhs, const Robot& rhs) { return (&lhs == &rhs); }
Explanation / Answer
Answer1 :
Ans is A as we want to reference the same simution we will use the existing Sensor and arena class reference
Answer2 :
Ans is A we need to compare the address of calling object with param object , here we will use this for current object and & for param to get address
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.