# 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:** 9

<div class="post-metadata">

**Author:** ![saurabh\_3](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/saurabh_3/32/3027_2.png) [@saurabh\_3](https://verificationacademy.com/forums/u/saurabh_3)\
**Post date:** [December 7, 2017, 6:34am UTC](https://verificationacademy.com/forums/t/question-on-inheritance-in-sv/33787/9 "2017-12-07T06:34:56Z")

</div>

_In reply to [Lina.Lin](https://verificationacademy.com/forums/t/question-on-inheritance-in-sv/33787/8):_

> _In reply to [saurabh\_3](https://verificationacademy.com/forums/t/question-on-inheritance-in-sv/33787/8):_  
> I update your code to have d3 as static, d4 as non-static and pass them to new(a,b). The sim result show display message as below. Not sure why you get 0 for both cases.  
> ZAM: **static a\_val: 6** non-static b\_val:0

```verilog

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

```

I am using vcs tool for your updated code ,getting result as  
ZAM: static a\_val: 6 non-static b\_val:6  
V C S S i m u l a t i o n R e p o r t

---

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