-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathq14.cpp
More file actions
51 lines (49 loc) · 773 Bytes
/
q14.cpp
File metadata and controls
51 lines (49 loc) · 773 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
51
#include <iostream>
#include <string.h>
using namespace std;
class student
{
int roll,age,clas ;
char name[10];
public:
student()
{
roll = 1;
age = 17;
clas = 12;
strcpy(name,"");
}
friend istream & operator >> (istream &obj,student &s)
{
cout <<"enter name:";
obj >> s.name;
cout <<endl<<"enter class:";
obj >> s.clas;
cout <<endl<<"enter roll no.";
obj >> s.roll;
cout <<"enter age:";
obj >> s.age;
return obj;
}
friend ostream & operator << (ostream &obj,student &s)
{
cout <<"name:";
obj << s.name;
cout <<endl<<"class:";
obj << s.clas;
cout <<endl<<"roll no.";
obj << s.roll;
cout <<"age:";
obj << s.age;
return obj;
}
};
int main()
{
student s,s1;
cin >> s;
cout << s;
cin >> s1;
cout << s1;
return 0;
}