First, don't use new and delete. Instead, use smart pointers. Then, you do not have to worry about ever using delete.
Second, this is wrong for how you have it.
SpriteVector.erase(it);
For what you have it should be something like
delete SpriteVector (*it);
(*it) = nullptr; //or = NULL
//or something similar to this, iterator access is something i dont use much so i can never quite remember how to use them
Third, why are you doing this to begin with?
Instead, you should not use pointers for these operations. Just creating an instance will suffice.
Example
Instead of
sf::Sprite* Sprite;
Sprite = new sf::Sprite;
....
sf::Texture* projectileImage;
projectileImage = new sf::Texture;
projectileImage->loadFromFile("fireball.png");
This can be made into
sf::Texture projectileImage("fireball.png");
sf::Sprite projectileSprite( projectileImage );
Also, instead of removing dead sprites (in this case projectiles no longer needed). Have a bool that says if it is active or not. Whenever you parse the projectile vector you can just check to see if it is active, and skip it if it is not. Then, when you need to make a new projectile, just find an inactive one and set it's variables to what you want the new one to be and activate it.
This is faster than deleting and pushing on the vector. Every time you delete something in a vector, the vector has to recopy everything that came after the one you deleted. So if you have 10 elements, and you delete the 3, it has to recopy 4-10. When you add a new one, then you have to make a copy, and in some cases the vector will grab a bunch more memory for later use. Instead, you should only make a new projectile if all your previous projectiles are still active.
Example
Instead of this...
for (iter it = SpriteVector.begin(); it != SpriteVector.end(); it++)
{
if ((it)->getPosition().y <= 600)
{
(it)->move(5, 5);
}
}
//RENDERING
window.clear();
for (iter it = SpriteVector.begin(); it != SpriteVector.end(); it++)
{
if ((it)->getPosition().y <= 600)
{
window.draw(*it);
}
if ((it)->getPosition().y >= 601)
{
SpriteVector.erase(it);
std::cout << "Erasing..." << (&it) << "Container size..." << SpriteVector.size() << "\n";
}
}
window.display();
I would do this...
//projectiles is a vector of projectiles
//projectile is a class that has a sf::Vector2f position, sf::Sprite sprite, and a bool isActive.
for(unsigned int i = 0; i < projectiles.size(); i++) //personal preference here. I prefer index access vs iterator access
{
if( projectiles[i].isActive )
{
projectiles[i].move(5,5);
}
if( projectiles[i].getPosition().y > 600 )
{
projectiles[i].isActive = false;
}
}
window.clear();
for(unsigned int i = 0; i < projectiles.size(); i++)
{
if( projectiles[i].isActive )
{
window.draw( projectiles[i].sprite );
}
}
window.display();