Is this a memory leak? Dynamic_cast

I'm pretty bad with this stuff so I'd like to ask just for 100% safety:

1
2
3
4
5
6
void function(Class* other){
   if(SubClass* t = dynamic_cast<SubClass*>(other)){
     //dostuff 
     //should I "delete t"? 
   }
}


Is this a memory leak? I don't want to accidentally delete "other" but I don't want some evil memory leaks either.
If you did not new, then you do not delete.

So no, that would not leak. And in fact deleting would be bad.
Last edited on
If the destructor is virtual there will not be a memory leak
Topic archived. No new replies allowed.