Thursday 8 August 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...