Thursday, August 8, 2019

c++ - Simple Guide to using pointers

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

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...