Basic class constructor:: new()
Every Class constructor has an implicit new() method
- When called, allocates memory to hold the properites
- Properties are set to the uninitialized value i.e X for 4-state , 0 for 2-state and " " for string
for ex:
class animal;
int age;
string name;
function new();
age = 1;
name = "Friend";
endfunction
endclass
module top();
animal a_h; // declare the class handle
initial begin
a_h = new();
$display("%0d '%s' ", a_h.age, a_h.name);
end
endmodule
Comments
Post a Comment