|
|
|
|
|
by pyrtsa
4665 days ago
|
|
Bjarne's advice also applies to pointers wrapped as class members. There are just too many ways you can mess things up inside the class when dealing with raw pointers, examples including: - partial construction: having to deal with already allocated pointers in case of errors during the construction
- copy construction: who owns the resources? (Alternatively, you'll need to remember to disable the copy constructor explicitly.)
- copy assignment: likewise Doing the Right Thing is just so much easier when you wrap those member objects into e.g. `std::unique_ptr<T>`. That'll disable copy construction and assignment, which means that you'll need to think of that separately if it's needed. |
|