jeudi 25 octobre 2018

Delete a vector

I have next c++11 code

#include <vector>
#include <string.h>

class TList {
private:
 std::vector<const char*> elementos;
 int position;
public:
 TList(const char** e, int s);
};

TList::TList(const char** e, int s) {
     std::vector<const char*> res (&e[0], &e[s]);
     elementos = res;
     position = 0;
}
int main()
{
    int size = 2;
    const char *arr[2] = {"Hola", "AAAA"};
    TList *list = new TList(arr, size);
    delete[]list;
    return 0;
}

When I run it in Visual Studio, it says "Exception thrown: read access violation. this was 0xD8D6A9B0" in the file "xutility" at the line 253, here:

#if _ITERATOR_DEBUG_LEVEL == 2
    if (_Myproxy != 0)

What is the problem? and what can I do?

Aucun commentaire:

Enregistrer un commentaire