Hello!
I am writing a program to overload ~ operator to reverse the given string.
Here is my program.
The problem message is that"Could not find a match for string::string(char).
I am writing my program on linux. I can not use strrev function.
#include<iostream.h>
#include<string.h>
class String
{
char str[20];
int count;
public:
String ()
{}
String (char*str1)
{
int i=0;
strcpy(str,str1);
while(str[i++]!='\0')
count++;
}
void operator~ ()
{
int j=0;
String str2[20];
for(int i=count;i>=0;i--)
str2[j++]=str[i]; //the problem is here.*****************
str2[j]='\0';
//return str2;
}
};
int main()
{
String s1("hello");
String s2();
~s1;
return 0;
}