Hi,
In the following code, there are few variables in parent class which I need to access the value of it in the child class. I created a task disp(), which is called to update the main variables of parent class to a temporary variable.
Later in the child class, I am calling the super,disp() task to access the variable values in child class and this is printing as ‘0’. What is the issue in the code and what are the ways to access only the parent class variable values inside child class.
class A;
int a;
int b;
int q[$];
int a1;
int b1;
int temp_q1[$];
task temp1;
a = 10;
b = 20;
q.push_back(1);
q.push_back(2);
$display("A is %h, B is %h", a,b);
$display("Queue size is %d", q.size());
disp();
endtask
task disp();
a1 = a;
b1 = b;
temp_q1 = q;
$display("Inside Parent disp() %d.....%d....$d",a1,b1,temp_q1.size());
endtask
endclass
class B extends A;
int q1[$];
int b_a1;
task temp2;
//super.temp1;
$display("B:: A is %d, B is %d", super.a,super.b);
$display("B:: Queue size is %d", super.q.size());
super.disp();
endtask
endclass
module temp1;
A a_0;
B b_0;
initial
begin
a_0 = new();
b_0 = new();
a_0.temp1();
b_0.temp2();
end
endmodule