Storing objects in STL vector - minimal set of methods
Posted
by osgx
on Stack Overflow
See other posts from Stack Overflow
or by osgx
Published on 2010-03-23T15:30:36Z
Indexed on
2010/03/23
15:43 UTC
Read the original article
Hit count: 190
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.
© Stack Overflow or respective owner