Namespace std not recognized in public API.h for shared library

Pages: 12
smart pointers are used as an 'owning' pointer. They 'own' the allocated memory and will automatically release when they go out of scope. unique_ptr can only be moved. They can't be copied. shared_ptr can be copied and when the last copy goes out of scope the memory is released. If say a function just requires access to the data to which a pointer points then just use a 'standard' pointer. Simply, you should never need a delete in the code.

I din't explicitly release the memory


For a class, allocate memory in constructor and release in the destructor (RAII). If you are allocating memory outside of a class or not in a class constructor then don't. Use say std::vector/std::array or a smart pointer to ensure that memory is always correctly released.
Last edited on
Topic archived. No new replies allowed.
Pages: 12