That sentence you quoted was just to give you ideas on how to solve this:
However, I noticed that my code inside the int main() function was too messy, especially with those sprites' and textures' declarations "cramming" the function.
Instead of having something like this
sf::Texture texture;
if (!texture.loadFromFile("image.png"))
{
// error
}
sf::Sprite sprite;
sprite.setTexture(texture);
sprite.setTextureRect(...);
window.draw(sprite);
You can create an class that does all of that for you. Your main would just then be:
MyDrawableClass object;
window.draw(object);
However, designing your code like this leads to other things you need to consider. For example, if you simply store your texture in an object, then every time you create a new object of the same type you will be making unnecessary copies of that texture. Typically, you would create some kind of full blown "resource manager" class (or use the ones in libraries like "thor") for your textures and similar resources.
Basically, the topic of how to structure your code is a pretty big one with several different answers. It may be hard for people to give full explanations here on the forums without skimping on the details. Again, I recommend looking around the internet for typical game design patterns, or if you don't mind spending a small amount of money, buying one of the
SFML game development books. I've actually never read the books myself, but I've heard that they can be a big help for beginners.