-
Notifications
You must be signed in to change notification settings - Fork 0
/
2nd.cpp
57 lines (46 loc) · 1.13 KB
/
2nd.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
#include<iostream>
using namespace std;
class Maths //Class Declaration
{
public: //Access Specifier
int iNo1; //Characteristics
int iNo2; //Characteristics
Maths() //Constructor (default)
{
cout<<"Inside default constructor\n";
iNo1 = 0;
iNo2 = 0;
}
Maths(int A, int B) // constructor (parametrized)
{
cout<<"inside Paramterized constructor\n";
iNo1 = A;
iNo2 = B;
}
~Maths() //Destructor
{
cout<<"Inside Destructor\n";
}
int Addition() //(Maths *this)
{
return iNo1 + iNo2 ; // Behaviour
}
int Substraction() // (Maths *this)
{
return iNo1 - iNo2 ; // Behaviour
}
};
int main()
{
cout<<"Inside main function\n";
Maths mobj1;
Maths mobj2(10,11);
int ret = 0;
ret = mobj2.Addition();
// ret = Addition(200)
cout<<"Addition is :"<<ret<<"\n";
ret = mobj1.Substraction();
// ret = Substraction(100)
cout<<"substraction is :"<<ret<<"\n";
return 0;
}