Accessing a class variable with a module variable

HI,
I have a code like this.


class reg_class;
int DWIDTH;
endclass
module tb;
string param = "DWIDTH";
reg_class u_reg_class;
initial begin
u_reg_class = new();
u_reg_class.param = 30;
$display("%d",u_reg_class.param);
//u_reg_class.$sformatf("%s",parma) = 30;
//$display("%d",u_reg_class.$sformatf("%s",param));
end
endmodule

I want to access that class variable.
I have tried commented lines also but not useful, giving an error like “Character immediately after a period(‘.’) does not start an identifier”
So the question is how can i access those class variable with internal module variable.

In reply to nag.chil:

You can not use a string datatype to reference a variable. You can only reference variables by their identifier.

The best you can do is make a function in reg_class which does a lookup based on a string passed in as a parameter.