Code35:Oops_local_Scope_data_member.sv - EDA Playground
Warning! This exercise has been opened in another tab; autosave has been disabled. Close this tab or refresh to reactivate.

 Languages & Libraries

 Tools & Simulators

 Examples

208


43
 
1
class first;
2
  
3
 local int data = 34;
4
  
5
  task set(input int data);
6
    this.data = data;
7
  endtask
8
  
9
  function int get();
10
  return data;   
11
  endfunction
12
  
13
  task display();
14
    $display("Value of data : %0d",data);
15
  endtask 
16
  
17
endclass
18
 
19
class second;
20
  
21
  first f1;
22
  
23
  function new();
24
    f1 = new();
25
  endfunction
26
   
27
endclass
28
 
29
 
30
module tb;
31
  
32
  second s;
33
  
34
  initial begin
35
    s = new();
36
    s.f1.set(123);
37
    $display("Value of data : %0d", s.f1.get());
38
    
39
  end
40
  
41
  
42
  
43
endmodule
xxxxxxxxxx
1
 
1
// Code your design here
2
16 views and 0 likes     
A short description will be helpful for you to remember your playground's details
 
100:0