EXC_BAD_ACCESS(code=1 ,address=0*8) in getting vector.size() function call

i am using c++ in Xcode, i had import <vector> in .hpp file,
all other function working properly
i had declare vector in track class

in track.hpp

class track{

public:

track();

std::vector<muteevent*> muterecordings;
}

*muteevent is another class i had declare

when i am using this vector into track.cpp
getting size of the vector into this class like that

for (int i=0; i< muterecordings.size();i++) {

delete muterecordings[i];

}

and it gives me EXC_BAD_ACCESS(code=1 ,address=0*8)
i dont know how to solve this error. my whole process stop by this error.
Hi,

Did you create muteevent with new? deleting something not created with new could give this error. Try to avoid using new / delete altogether - use an STL container and / or smart pointers instead. You shouldn't need new for items being put into a vector, vector already puts it's data on the heap.

Edit: provide some code we can compile.
Last edited on
Topic archived. No new replies allowed.