CWE-762: Mismatched Memory Management Routines
Even though most programmers understand what is the difference between objects and pointers to them, sometimes it is not entirely clear, which of the ways of accessing the object to choose. We have tried to answer this question below.
Sometimes, we need to create wrapper types. For example, types like
optional and similar.
Usually, these types have an accessor member function called
.get but they also provide the
operator-> to support direct access to the contained value similarly to what ordinary pointers do.
Many programmers are very fond of blaming the compiler for different errors. Let’s talk about it.