-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdestructor1.cpp
More file actions
50 lines (48 loc) · 1017 Bytes
/
destructor1.cpp
File metadata and controls
50 lines (48 loc) · 1017 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<conio.h>
using namespace std;
class student{
char name[20],add[20];
int roll, zip;
public:
student();
~student();
void read();
void disp();
};
student :: student(){
cout<<"Student Details"<<endl;
}
void student :: read(){
cout<<"Enter Student Name : "<<endl;
cin>>name;
cout<<"Enter Student Roll no : "<<endl;
cin>>roll;
cout<<"Enter Student Address : "<<endl;
cin>>add;
cout<<"Enter Student pincode : "<<endl;
cin>>zip;
}
void student :: disp(){
cout<<endl<<"Student Name : "<<name<<endl;
cout<<"Roll no : "<<roll<<endl;
cout<<"Address :"<<add<<endl;
cout<<"Zipcode : "<<zip<<endl;
}
student :: ~student(){
cout<<"\nStudent Details is closed and related object destroyed "<<endl;
}
int main(){
{
student s1 ;
s1.read();
s1.disp();
}
getch();
student s2 ;
s2.read();
s2.disp();
getch();
//destuctor will destroy both s1 and s2 object
return 0;
}