Question.1
A constructor parameter shadows a member variable:
class Servo { int pos; public: Servo(int pos) { pos = pos; // Line A } }; Servo s(90);
After construction, what is s.pos? (Assuming public access.)
s.pos
Select Answer
90 -- pos is set correctly
Garbage -- Line A assigns the parameter to itself; the member pos is never written because the parameter shadows it
0 -- default initialization
Compilation error -- duplicate name