I'm using vector with my own class type:
std::vector<CItem> m_vItems;
In my class I'm initializing SFML types like texture and sprite:
class CItem
{
(...)
sf::Texture m_Texture;
sf::Sprite m_Sprite;
sf::IntRect* m_pRect;
(...)
}
I'm trying to pass object to my vector declared as member of other class CLevel and I'm doing it inside method of that class like this:
CItem *temp = new CItem(x, y, kind);
m_vItems.push_back(*temp);
As you see, I'm not deleteing temp pointer with delete, but in destructor of class CLevel I've got a simple line:
std::vector<CItem>().swap(m_vItems);
And I'm little confused about memory leaks. Is my program has got some of these or the line above solving problem and my example has been correctly written?