-
Notifications
You must be signed in to change notification settings - Fork 0
/
4_RelationalOpearter.cpp
54 lines (42 loc) · 1020 Bytes
/
4_RelationalOpearter.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
/*Can we compare the reational operaters (==,!=,<=,>=) to compare 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(6,5);
// //Test:01
// cout<<obj1.getX()!=obj2->getX();
// /*error: no match for 'operator!=' (operand types are 'std::basic_ostream<char>' and 'int')
// cout<<obj1.getX()!=obj2->getX();*/
// //Test:02
// cout<<*(obj2)==obj1;
// //Compile time error Operation not defined
// Results:So its mean we will never compare the data member wise or agrement wise
delete obj2;
obj2=nullptr;
return 0;
}