-
Notifications
You must be signed in to change notification settings - Fork 0
/
5_ArithematicOpearter.cpp
57 lines (43 loc) · 1.03 KB
/
5_ArithematicOpearter.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
/*Can we compare the use the arithematic operaters (+,-,*,/,%) to perform arithematic calculations between two object data members ?
*/
#include<iostream>
using namespace std;
class algebra
{
public:
int x;
int y;
public:
void setData(int xA,int yA)
{
x=xA;
y=yA;
}
void getData()
{
cout<<"The value of x = "<<x<<endl;
cout<<"The value of y = "<<y<<endl;
}
//getters
int getX(){ return x;}
int getY(){ return y;}
};
int main()
{
algebra obj1;
algebra *obj2=new algebra;
obj1.setData(5,6);
obj2->setData(1,2);
// //Test:01
// //Member Wise
// cout<<obj1.getX()+obj2->getX()<<endl;
// cout<<obj1.getY()+obj2->getY()<<endl;
// //Test:02
// //Agremeent Wise
// cout<<*(obj2)+obj1<<endl;
// //Compile time error Operation not defined
//Results:We can perform the matematical opaertions on the object adat memebers only member wise not agremnet wise.
delete obj2;
obj2=nullptr;
return 0;
}