Computer Science, asked by divyamuchurami, 1 year ago

how to c++ in a clear manner???

Answers

Answered by Anonymous
1
A common idiom for clearing standard containers is swapping with an empty version of the container:

void clear( std::queue<int> &q ) { std::queue<int> empty; std::swap( q, empty ); }

It is also the only way of actually clearing the memory held inside some containers (std::vector)

Similar questions