«كُنْتُ نَهَيْتُكُمْ عَنْ زِيَارَةِ الْقُبُورِ، فَزُورُوهَا فَإِنَّهَا تُذَكِّرُ الْآخِرَةَ»
I had forbidden you to visit graves; now visit them, for they remind you of the Hereafter.
«كنت نهيتكم» explicitly refers to the earlier prohibition, while «فزوروها» establishes a later permission. There is no need to infer the order merely from the ages of narrators.
This illustrates a strong means of establishing naskh: an authentic prophetic statement itself specifies the former and subsequent ruling. The earlier prohibition was a real ruling for its period; its later removal does not erase that history.