UVM factory create in a class

In reply to jimmyhuang0904:

I understand what you want to do, but don’t understand what error you are getting.

Try calling
create_component()
instead.

if ( !$cast(child, create_component(get_type_name(), $sformatf("m_child_class%0d",children.size() ) 
     `uvm_fatal("ID","Failed because you didn't register this class with the factory")