Yes, another realloc
vs. std::vector
question. I know what you're going to say, and I agree, forget manual memory allocation, and just use a std::vector
. Well unfortunately my professor has forbidden me to use anything from the STL for this assignment.
So yeah, I have a dynamic array of T
and I need it to be resizable, and I can't use std::vector
. I could return to the dark ages and do the whole thing with malloc
and family, but if I could use new
that would be totally awesome.
I've read plenty of threads where everyone said "no, you can't do it, use std::vector
", but they were all posted before August 2011, and I'm hoping against hope that something might have changed since the dawn of C++11. So tell me, am I in luck, or do I have to revert to C style memory allocation?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…