Can we covergroup inside a monitor

In reply to chr_sue:

hai, chr_sue. I have gone through the same procedure but while calling the write method, it’s throwing an error saying that it’s a virtual function. Then I googled it and came to know that the subscriber write method is a pure virtual function. so declared as below

class fifo_coverage extends uvm_subcriber#(seq_item);
// …
…remaining code here

//
pure virtual function void write(fifo_seq_item item);
this.seq=item;
sync_fifo_cov.sample();
endfunction

endclass:fifo_coverage
//==============================================================================
error:
this.seq=item;
|
xmvlog: *E,EXPENC (/proj/22FDX/bolt/soc/b0/users/kvkumar/bolt_b0/tb/uvm_env/fifo_uvc/fifo_coverage.sv,29|7): Expecting the keyword ‘endclass’.

everything is perfect but I guess something is wrong with my write method? could you please correct me if I am wrong?