Why is this code throwing an exception?
It only happens when iterator array is created with malloc.
(I know I can use vectors and fix it but just curious to know the reason)
int count = 100;
std::list<std::wstring>::iterator* its = (std::list<std::wstring>::iterator*)malloc(sizeof(std::list<std::wstring>::iterator)*count);
std::list<std::wstring> list;
list.push_back(L"aaa");
list.push_back(L"bbbb");
std::list<std::wstring>::iterator it;
// no exception
it=list.begin();
//read access denied
its[0] = it;
I know that malloc doesn't call the constructor object, but here the copy contractor should be called in the last line, as far as I know the copy constructor should not have anything to do with previous initialization, correct me if I'm wrong
I'm not using "new " because I want an array of objects