Saturday, 23 June 2012

write a c++ program to consider the following class mystring

/*write a c++ program to 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<<"\nenter string:-";
       cin>>str;
       }
       void operator !();
};
void mystring::operator !()
       {
       int len;
       len=strlen(str);
       cout<<"\nreverse string is:-";
       for(int i=len-1;i>=0;i--)
       cout<<str[i];
       }
int main()
{
mystring m1;
clrscr();
m1.accept();
!m1;
getch();
return 0;
}
/*

enter string:-peer

reverse string is:-reep
*/

No comments: