In reply to panwei1988:
Have you looked at the Factory Override page on verification academy ?
https://verificationacademy.com/cookbook/usingfactoryoverrides
You should not need to use ‘delete’ anywhere in you code.
You should be using the set_type_override or set_inst_override methods as shown