-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathset.cpp
More file actions
50 lines (46 loc) · 999 Bytes
/
set.cpp
File metadata and controls
50 lines (46 loc) · 999 Bytes
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<iostream>
#include<set>
#include<string>
#include<vector>
using namespace std;
class student
{
string name;
int rn;
public:
student(string tname,int trn)
{
name=tname;
rn=trn;
}
bool operator <(student tmpstu)const
{
return(rn<tmpstu.rn);
}
friend ostream & operator <<(ostream & tempout,student & temp)
{
tempout<<"student name is="<<temp.name<<'\n';
tempout<<"mark="<<temp.rn<<'\n';
return(tempout);
}
};
int main()
{
vector<student>vivek;
vivek.push_back(student ("shradha",50));
vivek.push_back(student ("vivek",100));
vivek.push_back(student ("deep",23));
vivek.push_back(student ("vivek",100));
vector<student>::iterator index;
set<student>setvivek;
for(index=vivek.begin();index != vivek.end();index++)
{
cout<<*index<<endl;
setvivek.insert(*index);
}
set<student>::iterator svindex;
for(svindex=setvivek.begin();svindex!=setvivek.end();svindex++)
{
cout<<*svindex;
}
}