I would say that this is not a variable type, since you need to clear the memory. Java will clear your memory, but C ++ will not do it for you. Otherwise, it is important to manage your resources when there are exceptions.
On the plus side, you get what they call "deterministic finalization." Great benefit. See how the acronym "RAII" is. I think this is perhaps one of the most important idioms in C ++.
This means that "Resource initialization is initialization," but it really means: "When this destructor fires, I will cleanse you after you, even if there are exceptions." In practice, this means that any object that you create or open to close or delete can be used with a smart pointer. The smart pointer will clear after you. It is very, very powerful, as soon as you understand it and start using it. This makes your error checking, exception handling and resource cleanup code very simple.
source share