Regarding Construct in Class

Without constructing the new() construct, how to access the task &/or function of a particular class.?

with using static method one can access task or function defined in class without allocating memory.
code for refference

program test();
 
class a;
 static int p;

static task display();
int b=1;
 int c=1;
p=p+3;
c=c+1;
$display("value of p=%d b=%d c=%d",p,b,c);
endtask
 
endclass
 
initial
begin
a A=new;
A.display();     // without creating instance, i am able to access the display method            // Why ?
end
endprogram

A static method can be invoked without the need for creating an instance of a class.

module example();

class static_ex;

static task display();
int a;
a++;
$display("Welcome to static world");
$display("A is %0d",a);
endtask
endclass

initial
begin
static_ex stat_h;

//Choice 1: Using scope resolution
static_ex::display();

//Choice 2: Using class handle
stat_h.display();
end
endmodule

Any of the above two choices will satisfy your requirement.

Regards,
Vinay

In reply to vinayksbv_:

Thanks Vinay

Regards
Devam

May I know under what scenarios one might need to do this?

In reply to tejapan:
See my SystemVerilog OOP course for examples of how the UVM uses static class members.