In my header file I declare a variable within the scope of a class:
FaultModel<double> *fm_req_set_odom_px;
...which is conditionally initialised in the class constructor, depending on the value of a configuration file:
const char *configModel = ConfigReader->ReadString("FaultModel");
if (strcmp(configModel, "cyclic") == 0)
fm_req_set_odom_px = new CyclicFaultModel<double>();
My question is: do I need to wrap the delete with a conditional to check if the model was initialised or not, or is it safe to just delete it in either case?
if (fm_req_set_odom_px != NULL) // Is this necessary?
delete fm_req_set_odom_px;