-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patht15.cpp
More file actions
42 lines (30 loc) · 693 Bytes
/
Copy patht15.cpp
File metadata and controls
42 lines (30 loc) · 693 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
/*
-------------------initialization list in constructor ----------------
syntax for initialization
constructor(argument-list):initialization-section
{
assignment+other code;
}
*/
#include<iostream>
using namespace std;
class test{
int a;
int b;
public:
//test(int i,int j):a(i),b(j)
//test(int i,int j):a(i),b(j+i)
//test(int i,int j):a(i),b(2*j)
//test(int i,int j):a(i),b(a+j)
//test(int i,int j):b(j),a(i+b) garbage value will print in a because a is initialize first
{
cout<<"constructor is executed"<<endl;
cout<<"the value of a:"<<a<<endl;
cout<<"the value b:"<<b<<endl;
}
};
int main()
{
test t(3,4);
return 0;
}