169. Encapsulation

Question.7

A developer worries that calling getSpeed() is slower than accessing motor.speed directly:

class Motor {
   float speed;
public:
   inline float getSpeed() const { return speed; }
};

Is there a performance difference?

Need Help? Refer to the Quick Guide below

Select Answer

Restart quiz!