Selectively instantiate covergroup

In reply to dave_59:

Hi Dave
I tried below

function new(string name = "<class_name>", uvm_component parent);
      super.new(name,parent);

     if (!uvm_config_db#(<class_name>_cfg)::get(this, "", "cfg", cfg))
        `uvm_fatal("no_cfg", "You must pass a cfg thru config_db!");

     vif=cfg.vif

     cover_group=new(vif);  //I want to pass the vif get using config_db to covergroup new'ed
endfunction:new