Adding vector initialization to structure constructor
I have a structure that looks like this:
struct octNode{
octNode* parent;
octNode* child[8];
std::vector<int> pointIndex;
//constructor of the struct
octNode()
{
memset(parent,0,sizeof(parent));
memset(child,0,sizeof(child));
}
};
But this results in a runtime error: 0xC0000005: Location of access violation entry 0xcdcdcdcd. Unhandled exception at 0x771115de in Octree_octnode_0113.exe: 0xC0000005: Location of access violation entry 0xcdcdcdcd.
An access violation occurs when an empty vector is created. Is there a way to initialize the vector in the constructor so that the error doesn't occur?
+3
source to share