[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppSharedArray
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppSharedArray
(C++) boost::shared_array
Boost C++ library class used to manage a [CppPointer | pointer]] to a dynamically allocated array. The managed pointer can be copied freely. Only when the last managed pointer goes out of scope, the array is delete[]-ed.Example without boost::shared_array
int main() { const int size = std::rand() % 100; int * myArray = new int[size]; //Do stuff with myArray delete[] myArray; //Do not forget to call delete[] !!! }
- include <cstdlib>
Example with boost::shared_array
int main() { const int size = std::rand() % 100; boost::shared_array<int> myArray(new int[size]); //Do stuff with myArray //Cool, no need to call delete[] yourself }
- include <cstdlib>
- include <boost/shared_array.hpp>
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
