In reply to emin:
Without knowing exactly what you are trying to accomplish, it’s difficult to provide an answer.
When you instantiate param_class, you should know the two types that you are using as parameters. You could have two different functions, one that uses $cast and one that uses assignments, and use the appropriate version.
class param_class #(type type_foo = some_def_type,
type type_bar = some_def_type,
bit is_singular = 1);
type_foo foo;
type_bar bar;
function void some_func_singular();
$cast(foo, bar);
endfunction
function void some_func_non_singular();
foo = bar;
endfunction
function void some_func();
if (is_singular) some_func_singular();
else some_func_non_singular();
endfunction
endclass