Smart pointers should be used where they can as they provide better memory management and are by now a widely used pattern, recognized by any decent c++ programmer. If you're not doing any of what follows, you should probably use a smart pointer.
Raw pointers can be used for some things where smart pointers can't be used (as-is that is, they can be modified). You can use a pointer to point to an array (although in c++ it's better to use std::vector
), you can use pointers to undefined classes as a class member (using forward declarations), you can do pointer arithmetics, etc.
No comments:
Post a Comment