CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*Question : As class has all the member variables of int type and C++ knows how to sort int types, why can't class sorting work without < operator ?
Try uncommening sort statement and it will throw errors
In other words , we have vector<vector<int>> , then C++ by default sorts outer vector based on first element of inner vector.
Why this non uniformity?
*/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class myTest
{
public:
myTest(int id) : m_id(id) {}
void print()
{
cout << m_id << endl;
}
private:
int m_id;
};
int main()
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run