SystemVerilog OOP Mastery · All levels

this, Scope Resolution, and Automatic Lifetime: Interview Questions

Interview Questions for this, Scope Resolution, and Automatic Lifetime.

Interview questions

Q1. What bug does this.field = field prevent?

Answer: It prevents argument/member shadowing mistakes where field = field only updates the local argument and leaves the member unchanged.

Q2. If class methods are automatic, why can two calls still interfere?

Answer: Automatic applies to locals and arguments; both calls still read and write shared object members through this.

Related topics