Storing objects in STL vector - minimal set of methods
- by osgx
Hello
What is "minimal framework" (necessary methods) of object, which I will store in STL <vector>?
For my assumptions:
#include <vector>
#include <cstring>
using namespace std;
class Doit {
private:
char *a;
public:
Doit(){a=(char*)malloc(10);}
~Doit(){free(a);}
};
int main(){
vector<Doit> v(10);
}
gives
*** glibc detected *** ./a.out: double free or corruption (fasttop): 0x0804b008 ***
Aborted
and in valgrind:
malloc/free: 2 allocs, 12 frees, 50 bytes allocated.