-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdistructor.cpp
More file actions
34 lines (29 loc) · 773 Bytes
/
distructor.cpp
File metadata and controls
34 lines (29 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
#include <iostream>
using namespace std;
// *******Destructor never takes an argument nor does it return any value*******
int count = 0 ;
class Num
{
public:
Num(){
count++;
cout<<"This is the time when constructor is called for object number"<<count <<endl;
}
~Num(){
cout<<"This is the time when destru is called for object number"<<count<<endl;
count--;
}
};
int main()
{
cout<<"We are inside our main function"<<endl;
cout<<"Creating first object n1"<<endl;
Num n1;
{
cout<<"Entering this Block"<<endl<<"Breating two more objects"<<endl;
Num n2 ,n3;
cout<<"Exiting this block"<<endl;
}
cout<<"We are inside our main function back "<<endl;
return 0 ;
}