Difference between member and helper operators?

Why would I use one form over the other? Say.... I have an object called Student which has two member variables: an int that is the student ID and a string of every grade the student has received.

Now imagine I define the '+' operator to add a grade to the string. What is the difference between

Student Student::operator+(char g) {

and

Student operator+(const Student &stud, char grade)

aside from the obvious fact that one can refer to the current object in the former?

As you can see, I'm truly a beginner!
Last edited on
No, there's no different but this Student operator+(char grade, const Student &stud) is different since it enables to write 'A' + studend otherwise you can only write studend + 'A'
Thank you, that's all I needed to know.

I was aware of the "A + Student" thing and the need to code the reverse :)
Last edited on
Topic archived. No new replies allowed.