Code: Select all
void Body::setOrbit(Orbit* _orbit)
{
if (orbit == NULL)
delete orbit;
orbit = _orbit;
}
Is it correct about if (orbit == NULL) delete orbit; or should it be:
Code: Select all
if (orbit != NULL)
delete orbit;
Code: Select all
void Body::setOrbit(Orbit* _orbit)
{
if (orbit == NULL)
delete orbit;
orbit = _orbit;
}
Code: Select all
if (orbit != NULL)
delete orbit;
Code: Select all
void Body::setOrbit(Orbit* _orbit)
{
if (orbit != NULL)
delete orbit;
orbit = _orbit;
}
Code: Select all
void Body::setOrbit(Orbit* _orbit)
{
if (orbit == NULL)
delete orbit;
orbit = _orbit;
}