Why is the argument here const student &s?

why is const and & used in the argument??

hello @mehulbhandari358

Constant is something that doesn’t change. In C language and C++ we use the keyword const to make program elements constant. const keyword can be used in many contexts in a C++ program.
we dont want to change student data ,that why using const keyword.

&-> operator is used to indecate that data is passed by refernce.

to know why & operator. u should understand the difference between pass by refernce and pass by value.
i woulf recommend to read this article -> link
and then u will understand why we have used & .

I understand that its passed by reference but what is the need to pass by reference when we are only comparing them??

when we pass object as reference then it takes less time ,compared to when we pass object as value ( because pass by value involves copying)

this is the only reason .