Try this fix: *‘friend myString operator+( * const myString& stString, const char * ndString )’ and add const to all appropriate declarations and definitions.
expression evaluation fails to succeed
class myString {
public:
myString(int number) {}
myString(myString& paramMyString) {}
myString(myString&& paramMyString) {}
friend myString operator+(const char stString, const myString& ndString);
friend myString operator+(const myString& stString, const char* ndString);
friend myString operator+(const myString& stString, const myString& ndString);
DWORD length() {
return 9;
}
myString& operator=(myString& rhs)
{
return *this;
}
myString& operator=(myString&& rhs)
{
return this;
}
};
myString operator+(const char stString, const myString& ndString)
{
myString rr(0);
return rr;
}
myString operator+(const myString& stString, const char* ndString)
{
myString rr(0);
return rr;
}
myString operator+(const myString& stString,const myString& ndString)
{
int ndString_len=ndString.length();//<----HERE ERROR
myString rr(0);
return rr;
}
Above is code for class that I defined + operator. Following fails to evaluate.
/*
myString kk(8);
myString pp = (kk+" ")+"h";
I entered brackets so It should better understand in which priority compiler should execute
overloading operands but it fails to do operator + on (kk+" ") first and secondly on result + "h".
Can I do it?
How to do it?*/
I added const before each myString& and I am getting other kind of errors:
IN myString operator+(const myString& stString,const myString& ndString)
I AM GETTING error in int ndString_len=ndString.length();
It says it is error about CONST word BUT I cannot understand how to make it working.
HOW CAN I FIX IT?