-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path04_constructor.cpp
More file actions
47 lines (42 loc) · 862 Bytes
/
Copy path04_constructor.cpp
File metadata and controls
47 lines (42 loc) · 862 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
#include <iostream>
using namespace std;
class Customer
{
string name;
int account_number;
int balance;
public:
// default constructor
Customer()
{
name = "sakshi";
account_number = 5;
balance = 100;
}
// parameterized constructor
Customer(string name, int account_number, int balance)
{
this->name = name;
this->account_number = account_number;
this->balance = balance;
}
//constructor overloading
Customer(string a,int b){
name= a;
account_number=b;
balance=50;
}
void display()
{
cout << name << " " << account_number << " " << balance << endl;
}
};
int main()
{
Customer A1;
Customer A2("swapnil", 10, 4000);
Customer A3("Manisha",46);
A1.display();
A2.display();
A3.display();
}