-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path27_oops.cpp
More file actions
42 lines (39 loc) · 852 Bytes
/
27_oops.cpp
File metadata and controls
42 lines (39 loc) · 852 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
#include<iostream>
using namespace std;
/* stntax for initialization list in constructor:
constructor (argument-list):initilization-section
{
assigmrnt + other code;
}
class Test{
int a;
int b;
public:
Test(inti,int j): a(i),b(j)
{
cout<<"constructor execution "<<endl;
cout<<"the value of a is"<<" "<<a<<endl;
cout<<"the value of b is"<<" "<<b<<endl;
}
};
*/
class Test{
int a;
int b;
public:
// Test(int i,int j): a(i),b(j)
// Test(int i,int j): a(i),b(i+j)
// 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+j)--> give guarbage value beacuse a initialize first
Test(int i,int j): a(i),b(j)
{
cout<<"constructor execution "<<endl;
cout<<"the value of a is"<<" "<<a<<endl;
cout<<"the value of b is"<<" "<<b<<endl;
}
};
int main(){
Test k(2,5);
return 0;
}