-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoops.cpp
More file actions
53 lines (53 loc) · 1.04 KB
/
oops.cpp
File metadata and controls
53 lines (53 loc) · 1.04 KB
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
52
53
#include<bits/stdc++.h>
using namespace std;
class student{
string name;
public:
int age;
bool gender;
student(){
cout<<"Default constructor"<<endl;
}
student(string s, int a, int g){
cout<<"Parameterized constructor"<<endl;
name=s;
age=a;
gender=g;
}
student(student &a){
cout<<"Copy constructor"<<endl;
name=a.name;
age=a.age;
gender=a.gender;
}
~student(){
cout<<"destructor called"<<endl;
}
void setName(string s){
name=s;
}
void getName(){
cout<<name<<endl;
}
void print(){
cout<<"Name: "<<name<<endl;
cout<<"Age: "<<age<<endl;
cout<<"Gender: "<<gender<<endl;
}
};
int main(){
student arr[3];
for(int i=0; i<3; i++){
string s;
cin>>s;
arr[i].setName(s);
cin>>arr[i].age;
cin>>arr[i].gender;
}
for(int i=0; i<3; i++){
arr[i].print();
}
student a("pol", 8, 0);
student b;
student c=a;
}