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.
6 ответов
+ 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;
}
+ 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)
+ 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.
+ 1
i don´t have an idea
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;
}
0
doesn´t correct