If you're doing this from inside a custom scene node or animator then you can use smgr->addToDeletionQueue instead.
You'll have to define exactly what you mean by "didn't work" though. If you mean it crashed your program like "delete cube" did, then you're doing something wrong with memory management. If you mean it wasn't removed from the scene graph then you're creating more than one cube but only removing one of them.