No, if the purpose of the function is to instantiate some data and hand it over to some other object. A (hypothetical) example from the games industry:
void AddProjectileAtPoint(int x, int y)
{
Projectile *p = new Projectile(x, y);
mProjectileManager->Add(p); //"mProjectileManager"'s job is to hold all projectiles and update them every frame...
}
In this case the purpose explicitly is to create a new object representing some data and store it somewhere for later use.
Obviously, there will need to be a matching delete
at some point, but not within the function where the new
occurs. This is fine as long as there is a clearly defined procedure for passing responsibility for managing the new
'd memory to some other component.
In this case the structure is that the "Projectile Manager" takes responsibility for all projectiles it is given, will keep them alive for as long as is required and will clean-up the memory when it is appropriate.