0

Write a  ,not equal , greater or equal

Write a  ,not equal , greater or equal, smaller or equal? Define the two numbers to be data members of the class and then define a function named comparison to include all the comparison statements inside the function. No constructor or destructor should be used when you pass the values to the data members. 

1st Nov 2021, 5:02 AM
Younis Ahmad
Younis Ahmad - avatar
6 Respostas
+ 2
I set up a template for you with one example filled in. See if you can complete the rest #include<iostream> using namespace std; class compare{ public: bool notEqual(int x, int y){ return x!=y; } /* bool greatEqual(){ } bool lessEqual(){ }*/ }; int main() { int c,d; cin>>c; // enter 1st number cin>>d; // enter 2nd number compare nums; cout << nums.notEqual(c,d); return 0; }
1st Nov 2021, 10:51 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
Yeah, try to implement what @Rik Wittkopp said and show us your attempt. You can't just get the answers to your questions (assignment questions probably)
1st Nov 2021, 6:14 AM
Rishi
Rishi - avatar
+ 2
It seems there are multiple parts to this question 1. Define a class 2. Create a method to go in the class 3. The method should show the results of all the comparisons named when 2 numbers are used as the arguments / parameters Not equal != greater or equal >= smaller or equal <= Good luck with your assignment.
1st Nov 2021, 5:19 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
i don´t have an idea
1st Nov 2021, 5:03 AM
Younis Ahmad
Younis Ahmad - avatar
0
#include<iostream> using namespace std; class compare{ public: int x,y; int g() { return x!=y; x<=y; x>=y; } }; int main() { int c,d; cout<<"enter number of c="; cin>>c; cout<<"enter number of d="; cin>>d; compare set(c,d); cout<<set.g()<<endl; return 0; }
1st Nov 2021, 8:05 PM
Younis Ahmad
Younis Ahmad - avatar
0
doesn´t correct
1st Nov 2021, 8:24 PM
Younis Ahmad
Younis Ahmad - avatar