CoverPoint declaration for Dynamic Array

In reply to dave_59:

So, Currently the simulation has compilation error since i have added this portion of the code.
It is not happy about This particular line
“my_cg m_my_cg1;” and states it as “Syntactically this identifier appears to begin a datatype but it does not refer to a visible datatype in the current scope.”

Thus please let me explain the code structure:

class my_fcov extends uvm_subscriber #(my_sqi);

covergroup my_cg with function sample(bit cp_s);
coverpoint cp_s;
endgroup

my_cg m_my_cg1;

extern function new(string name, uvm_component parent);
extern virtual function void write(my_sqi t);

endclass

function my_fcov::new(string name, uvm_component parent);
m_my_cg1 = new[P_NUM];
foreach (m_my_sqi.my_variable[i]) m_my_cg1[i] = new();

endfunction: new

function void my_fcov::write(my_sqi t);

foreach (m_my_sqi.my_variable[i]) m_my_cg1[i].sample(m_my_sqi.my_variable[i]);

endfunction:write

As the part of coverage i haven’t been able to see anything as it has a compilation error itself.