My assignment is to create a structs and sort all the employees by last name, first name, id number and salary. I am confused on how to compare all of their last names in a function. If someone can help or provide a hint, that'd be helpful!
Variable, function, and (custom) type names do not need to "stand for" anything, like in
1 2 3 4 5
for ( int i=0 i < 42; ++i ) {
for ( int j=0 j < 7; ++j ) {
// something
}
}
the 'i' and 'j' do not reveal what the loops iterate over (which is of course questionable coding style).
Nevertheless, when you have a binary operator, such as <, in use: foo < bar
the 'foo' is on the left-hand side of < and
the 'bar' is on the right-hand side of <
In the example of std::sort there were: bool myfunction (int i, int j) { return (i<j); }
Would it be more or less clear, if the variables had been renamed like this: bool myfunction (int lhs, int rhs) { return (lhs<rhs); }