dimanche 12 mars 2017

Using **new** to allocate a contiguos space vs using a vector?

Hey guys following is a piece of code I encountered:

// Why use a new memory location like this when we have vectors?
// Are there any Advantages?
bool* arr = new bool(size);
// I am not clear what this line does but what I feel is 
// this std::memset sets whatever param2 is given over all
// locations starting from address at param1 and ends at the
// given size
std::memset(arr, 0, sizeof(bool) * (num+1));

Thanks a lot for answering, please be as clear and deep(knowledge kinda deep) as possible.

Aucun commentaire:

Enregistrer un commentaire