You are not creating any vectors at all with malloc.
Unless you are interfacing with some third party library that requires a parameter created with malloc, there is never any need to use it in C++ code.
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman
I'm new for STL.
And my previous code was programmed that way but at that time, I use the struct below so the code work fine.
But now, I replace this struct with std::vector so I think i will work the same.
Calls the row vector constructor, with SUBPATTERN elements in the row,
each with a value of vector<VEC_INT>(SUBPATTERN)
vector<VEC_INT>(SUBPATTERN)
Constructs a column, with SUBPATTERN elements in the column,
each with a value of VEC_INT (empty int vector).
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman
Well, first off, be absolutely sure that assigning a vector is really what you want to do. It can be an expensive operation. If you need to move a vector from one place to another, it's almost always cheaper to swap it with the one that's already there instead. Of course, if you need two copies of the vector then that won't work.
Bookmarks