座標(0,0)から右に向かって移動する円を管理するマネージャークラスを作ったのですが聞きたいことがあります。
//ヘッダー
Sphere sphere[10];
//cpp
SphereMgr::SphereMgr()
{
for(int i = 0 ; i < 10 ; i++)
sphere[i] = NULL;//null初期化
}
SphereMgr::~SphereMgr()
{
delete[] sphere;
}
SphereMgr::create()
{
static int count = 0;
count++;
if(count % 10 == 0)
{
for(int i = 0 ; i < 10 ; i++)
{
if(sphere[i] == NULL)
{
sphere[i] = new Sphere();
break;
}
}
}
}
SphereMgr::calc()
{
for(int i = 0 ; i < 10 ; i++)
{
if(sphere[i] != NULL)
{
sphere[i]->calc();
if(/*画面外に出たら*/)
{
delete sphere[i];
sphere[i] = NULL;
}
}
}
}
deleteとNULL初期化の決定的な違いがわかりません。
deleteだけやってはNULLではないので11コ目~はでないと思いますが、NULLの前にdeleteを書く理由が知りたいです。
このdeleteがないとどのようなことが起きるのでしょうか?
龍神録C++でもやっていたので(それと「nullptr」とはなんなのでしょうか?)