Created
November 27, 2018 12:39
-
-
Save Petingo/8ad07f7c0dd77dac01485bdc105b4b58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
class Student { | |
public: | |
int no; | |
string name; | |
Student() = default; | |
Student(int no, string name) { | |
this->no = no; | |
this->name = name; | |
} | |
bool operator<(const Student &other) const { return this->no < other.no; } | |
}; | |
int main() { | |
Student student[3] = {{3, "Terry"}, {1, "Tom"}, {2, "Dickson"}}; | |
sort(student, student + 3); | |
for (int i = 0; i < 3; i++) { | |
cout << student[i].no << " " << student[i].name << endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment