If we go according to below code
class A;
int a = 10;
endclass
class B extends A;
int b = 20;
endclass
program test;
A a1;
B b1;
initial begin
b1 = new();
a1 = b1;
$display("Value of variable b is %x", a1.b);
end
endprogram
Then the above code leads to the error: “Could not find element“ b ”in class“ A ”
Now I observe that when an extended class object is assigned to a base class descriptor, then the simulator checks the type of the descriptor and checks whether a variable is present in this class or not. Because the variable b is not defined in the base class, it will lead to error.
So, I want to confirm the correctness or incorrectness of the above, my?
I would appreciate if someone wants to add something to my observation, if this is the right but.
thanks