Click here to Skip to main content
15,860,972 members
Articles / General Programming
Alternative
Tip/Trick

C++ Tip: Aware of the confusion between delete with delete[]

Rate me:
Please Sign up or sign in to vote.
4.80/5 (4 votes)
1 Oct 2010CPOL 11.2K   1   2
The C++ comes with a rich standard library: the STL (Standard Template Library).So, why we should re-invent the wheel while we already have it done, safe and written to be light-weighed and performant?It's too much better to use the vector Class (Standard C++ Library)[^]:#include...
The C++ comes with a rich standard library: the STL (Standard Template Library).
So, why we should re-invent the wheel while we already have it done, safe and written to be light-weighed and performant?
It's too much better to use the vector Class (Standard C++ Library)[^]:

C++
#include <vector>

...

std::vector<int> a(10); // Pre-allocate an array of 10 int

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer Cutlite Penta S.r.l.
Italy Italy
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
General+5 for ease of problem solving. If you're dealing with a fix... Pin
Andrew McAuley7-Oct-10 6:53
Andrew McAuley7-Oct-10 6:53 
GeneralReason for my vote of 5 Thanks for answering like this - I'm... Pin
Aescleal1-Oct-10 9:49
Aescleal1-Oct-10 9:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.