Search Results

Search found 1 results on 1 pages for 'user11869'.

Page 1/1 | 1 

  • calling resize on std vector of pointers crashed

    - by user11869
    The problem can be reproduced using VS 2013 Express. It crashed when internal vector implementation tried to deallocate the original vector. However, the problem can solved by using 'new' instead of 'malloc'. Anyone can shed some light on this? struct UndirectedGraphNode { int label; vector<UndirectedGraphNode *> neighbors; UndirectedGraphNode(int x) : label(x) {}; }; int main(int argc, char** argv) { UndirectedGraphNode* node1 = (UndirectedGraphNode*)malloc(sizeof(UndirectedGraphNode)); node1->label = 0; node1->neighbors.resize(2); return 0; }

    Read the article

1