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

<div class="post-metadata">

**Author:** ![LinaLin20](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/l/34f0e0/32.png) [@LinaLin20](https://verificationacademy.com/forums/u/LinaLin20)\
**Post date:** [December 7, 2017, 5:41am UTC](https://verificationacademy.com/forums/t/question-on-inheritance-in-sv/33787/7 "2017-12-07T05:41:31Z")

</div>

_In reply to [saurabh\_3](https://verificationacademy.com/forums/t/question-on-inheritance-in-sv/33787/6):_

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

```

---

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