-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlec2.cpp
82 lines (63 loc) Β· 1.29 KB
/
lec2.cpp
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include<iostream>
using namespace std;
class Customer
{
string name;
int acc_no;
int balance;
int * roi;
public:
// Default constructor
Customer()
{
cout<<"Construcor is called "<<endl;
name = " ";
acc_no = 0;
balance = 0;
}
// //Parameterised
// Customer(string a , int b , int c)
// {
// name = a;
// acc_no = b;
// balance = c;
// }
// this pointer
// Customer(string name , int acc_no , int balance)
// {
// this->name = name;
// this->acc_no = acc_no;
// this->balance = balance;
// }
// constructor overloading
Customer(string a , int b )
{
name = a;
acc_no = b;
balance = 0;
}
// inline constructor
inline Customer(string a , int b , int c) : name(a) , acc_no(b) , balance(c) {}
void display()
{
cout<<name<<endl;
cout<<acc_no<<endl;
cout<<balance<<endl;
}
~Customer()
{
cout<<"Destructor is called "<<endl;
delete roi;
}
};
int main()
{
Customer c1;
c1.display();
Customer c2("Jashan" , 124, 50000);
c2.display();
Customer c3("Jashan" , 134);
Customer *c4;
c4->display();
delete c4;
}