This is probably a dumb question, born from my own ignorance, but I haven't been able to find a satisfying answer yet.
In this post Savlon gives example code for using SpriteRenderer to cycle through two sprites. What exactly is the purpose of the line:
private SpriteRenderer spriteRenderer;
To me this looks like we are storing an instance of the class SpriteRenderer inside the private pointer spriteRenderer. Because in the Start loop they write
spriteRenderer = GetComponent<SpriteRenderer>();
which uses GetComponent to address properties of SpriteRenderer.
Is this correct? If so, what is the advantage to doing this over creating Savlon's code inside a subclass of the SpriteRenderer class?