Consider the following class mystring
class mystring
{
char str[100];
public:\\methods
};
overload operator "!" to reverse case of each alphabet in the string
#include<iostream.h>
#include<string.h>
#include<conio.h>
class mystring
{
char str[100];
public:void accept()
{
cout<<"\n Enter string:-";
cin>>str;
}
void operator !();
};
void mystring::operator !()
{
int len;
len=strlen(str);
cout<<"\n Reverse string is:-";
for(int i=len-1;i>=0;i--)
cout<<str[i];
}
int main()
{
mystring m1;
clrscr();
m1.accept();
!m1;
getch();
return 0;
}
======================================================
OUTPUT :-
Enter string:-stop
Reverse string is:-pots
class mystring
{
char str[100];
public:\\methods
};
overload operator "!" to reverse case of each alphabet in the string
#include<iostream.h>
#include<string.h>
#include<conio.h>
class mystring
{
char str[100];
public:void accept()
{
cout<<"\n Enter string:-";
cin>>str;
}
void operator !();
};
void mystring::operator !()
{
int len;
len=strlen(str);
cout<<"\n Reverse string is:-";
for(int i=len-1;i>=0;i--)
cout<<str[i];
}
int main()
{
mystring m1;
clrscr();
m1.accept();
!m1;
getch();
return 0;
}
======================================================
OUTPUT :-
Enter string:-stop
Reverse string is:-pots