Runtime error: access violation while using .push_back () with std :: vector?

I have a vector defined std::vector<LPDIRECT3DTEXTURE9> textures;Later, I pass an object to it LPDIRECT3DTEXTURE9, for example textures.push_back(texture);Here is an example of this:

void SpriteManager::AddSprite(float x, float y, float z, LPDIRECT3DTEXTURE9 texture)
{
    //snip
    textures.push_back(texture);
    //snip
}

This causes a runtime error. It breaks a vector class into a function size(). Why can this happen?

Edit:

I also encounter the same problem performing the same operation on an object vector D3DXVECTOR3. Since it LPDIRECT3DTEXTURE9is a pointer to IDIRECT3DTEXTURE9, should I use this instead?

+3
source share
3 answers

, . textures SpriteManager. , , SpriteManager. this ?

0

, LPDIRECT3DTEXTURE9 , ( ), , , fandango push_back().

, , , . , push_back() , , .

+1

Your vector is damaged. I would suggest placing a data watchpoint on my internal elements to see what is stomping on it (in the debugger).

+1
source

Source: https://habr.com/ru/post/1724012/


All Articles