In reply to manishp.p18:
A parameterized class is a generic type, not a concrete type. It’s only when the class has been specialized by instantiation or a typedef during elaboration that references are checked. You could have written the class with no default type
class stack #(type T);
local T items[];
task push( T a );
a.variable_in_a
... endtask
task pop( ref T a ); ... endtask
endclass
The only difference is that you are required to provide a parameter when you instatiate. In both cases, the reference is not checked until after the final result of the parametrization is known.
Your side observation is incorrect. A virtual method can access anything available from the class it is declared in. On the other hand, a class variable has visibility to only the members or methods that have been declared in the class type of the variable. You can assign a derived subclass handle to a base class variable and call the virtual method in the subclass.