I need to do some logical comparison and return a boolean answer.
Here is the code from the .cpp file:
bool MyString::operator==(const MyString& other)const
{
if(other.Size == this.Size)
{
for(int i = 0; i < this.Size+1; i++)
{
if(this[i] == other[i])
return true;
}
}
else
return false;
}
Here is what is called from main.cpp file:
if (String1 == String4)
{
String3.Print ();
}
else
{
String4.Print ();
}
Here are there compiling errors I get:
error: request for member `Size` in `this`, which is of non-class type `const MyString* const`
error: no match for `operator[]` in `other[i]`
if(this[i] == other[i]) return true;This is going to cause you problems later. Think about what you're doing there.