-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCODE21.cpp
More file actions
29 lines (27 loc) · 813 Bytes
/
CODE21.cpp
File metadata and controls
29 lines (27 loc) · 813 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
#include <iostream> //LEARN CONSTRUCTOR
using namespace std;
class Constructor
{
int a,b;
public:
void Getdata(void)
{
cout<<"this is your a "<<a<<endl<<"this is your b "<<b<<endl;
}
Constructor(int ,int ); //THE NAME OF CLASS AND THE NAME OF CONSTRUCTOR WILL BE SAME ALWAYS
};
Constructor::Constructor(int x,int y) //DECLARE THE CONSTRUCTOR BY SCOPE RESOLUTION LIKE FUNCTION CALL
{
a=x;
b=y;
}
int main()
{
Constructor a1(1,2);
a1.Getdata();
Constructor b1= Constructor (1,2);
b1.Getdata();
}
// Constructor::Constructor(int x,int y)
// ^ ^ ^ ^
// Constructor a1 ( 1 , 2);