Really need your help, reference and opinion about the next task.
Without using the string library functions, I have to write a method using the overloading operator function which will receive as a parameter an int and return the character which is located on that specific int index.
check the code below pls,
note - (STRLEN)- method which I've written in a specific way and is doing exactly the same as the strlen one from cstring. It can work perfectly with objects as well.
charoperator[](constint x)
{
int n=this->STRLEN();
int index;
for(int i=0; i<n; i++)
{
if(this->str[i]==x) index=i;
}
return str[index];
}
int main()
{
STR A;
A="ababcdefg";
[A](6); // I am expecting char"e" to be returned but I am facing a couple of errors.
return 0;
}
@seeplus, many thanks, even though I am facing same compile errors as previous :
[Error] expected identifier before numeric constant
[Error] expected ',' or '...' before numeric constant
In lambda function
[Error] expected '{' before ';' token