Jump to content

C++: Difference between revisions

11 bytes added ,  23 October 2019
no edit summary
No edit summary
Line 162: Line 162:
* Call a clear/shrink/deallocate function
* Call a clear/shrink/deallocate function
Example [https://stackoverflow.com/questions/3054567/right-way-to-deallocate-an-stdvector-object Reference]:
Example [https://stackoverflow.com/questions/3054567/right-way-to-deallocate-an-stdvector-object Reference]:
<syntaxhighlight>
<syntaxhighlight lang="cpp">
// Using smart pointers
// Using smart pointers
std::unique_ptr<std::vector<float>> my_vector = make_unique<std::vector<float>>(99);
std::unique_ptr<std::vector<float>> my_vector = make_unique<std::vector<float>>(99);