design a class to overload the function compare () follows;
1. void compare (int,int)_to compare two integer valaue and print the greater of two integers .
2. void compare (char,char)-to compare the numeric value of two characters and print with higher numeric value.
3.void compare (string,string)-to compare the length of two strings and the print longer of the two .plse do it fast it is argent....
Answers
Answered by
1
Answer:
#include<cstring>
class check
{
int a, b;
public :
void compare( int x, int y)
{
a=x; b=y;
if(a>b) cout<<a;
else cout<<b;
}
void compare( char x, char y)
{
a=x; b=y;
if(a>b) cout<<a;
else cout<<b;
}
void compare( char x[ ], char y[ ])
{
a=strlen(x) ; b=strlen(y) ;
if(a>b) cout<<a;
else cout<<b;
}
};
Similar questions
Math,
4 months ago
Environmental Sciences,
4 months ago
Social Sciences,
4 months ago
Physics,
10 months ago
Social Sciences,
1 year ago
Physics,
1 year ago
Math,
1 year ago