The correct implementation of new will throw std::bad_alloc on failure, not return 0. Visual C++ 6 was the last compiler I know to just return 0, and you'd be crazy to be using that nowadays. If you want to allocate memory without throwing an exception, you can use new(std::nowthrow).
Because of this your example has the potential to leak a's memory if b fails, so you need to either catch the exception or use something like boost::scoped_array. It amazes me that people still don't know about RAII in C++.
Perhaps you should re-learn basic algorithm and data structure theory, because bubblesort can beat the pants off quicksort when the data set is small enough. Anyway, if you're going to implement quicksort, don't you want a 20-30% faster quicksort?
Lua's said to be the number 1 scripting language for making games. Surely it deserves a mention.
Poor Lua never gets the respect it deserves.
The correct implementation of new will throw std::bad_alloc on failure, not return 0. Visual C++ 6 was the last compiler I know to just return 0, and you'd be crazy to be using that nowadays. If you want to allocate memory without throwing an exception, you can use new(std::nowthrow).
Because of this your example has the potential to leak a's memory if b fails, so you need to either catch the exception or use something like boost::scoped_array. It amazes me that people still don't know about RAII in C++.
Perhaps you should re-learn basic algorithm and data structure theory, because bubblesort can beat the pants off quicksort when the data set is small enough. Anyway, if you're going to implement quicksort, don't you want a 20-30% faster quicksort?