OOCP3-6

//BCA Support //www.bcasupport.xyz #include <iostream.h> #include <conio.h> class distance { int feet,inch; public: distance(int f,int i) { feet=f; inch=i; } int operator==(distance &d) { if(feet==d.feet&&inch==d.inch) return 1; else return 0; } int operator>(distance &d) { if(feet>d.feet&&inch>d.inch) return 1; else return 0; } int operator<(distance &d) { if(feet<d.feet&&inch<d.inch) return 1; else return 0; } }; int main() { clrscr(); distance d1(5,5),d2(5,5),d3(1,1),d4(2,2); if(d1==d2) cout<<"\nBoth objects (d1 & d2) are equal"; if(d3<d4) cout<<"\nObject d3 is smaller"; if(d4>d3) cout<<"\nObject d4 is greater"; getch(); return 0; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.