# Question on Inheritance in SV

**URL:** <https://verificationacademy.com/forums/t/question-on-inheritance-in-sv/33787>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, Inheritance\
**Created:** [December 6, 2017, 5:18pm UTC](https://verificationacademy.com/forums/t/question-on-inheritance-in-sv/33787 "2017-12-06T17:18:54Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![srbeeram](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@srbeeram](https://verificationacademy.com/forums/u/srbeeram)\
**Post date:** [December 7, 2017, 10:51am UTC](https://verificationacademy.com/forums/t/question-on-inheritance-in-sv/33787/12 "2017-12-07T10:51:12Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/question-on-inheritance-in-sv/33787/11):_  
Hi Dave, could you please clarify the following. in the following code from above example, are d1 ,d2 and d3 get created and assigned with default value of 0 before super.new(d3) , and assigned with the values d1=4, d2=c2 and d3=6 immediately after super.new(d3) in the D class constructor.

```verilog

class D extends C;
   int d1 = 4;
   int d2 = c2;
   int d3 = 6;
function new;
   super.new(d3);
endfunction
endclass

```

I am expecting that way as I am getting the value of d3 as 6 in the below code. could you please clarify.

```verilog

module top;
class C;                                                 
   int c1 = 1;
   int c2 = 1;
   int c3 = 1;
function new(int a);
   $display("ZAM: a_val: %d",a); // always getting display as 0
   c2 = 2;
   c3 = a;
endfunction
endclass
 
class D extends C;
   int d1 = 4;
   int d2 = c2;
   int d3 = 6;
function new;
   super.new(d3);
   $display("value of d3 %d",d3);
endfunction
endclass
 
 
D d1=new();
initial begin
end
endmodule

```

---

_[View the full topic](https://verificationacademy.com/forums/t/question-on-inheritance-in-sv/33787)._
