When doing this:
CString filePath = theApp->GetSystemPath() + "test.bmp";
You are trying to sum two pointers of type const char*
. As the compiler is telling you, there is no overload of operator +
that accepts two pointers of type const char*
s as its input (after all, what you want is not to sum the pointers, but to concatenate the zero-terminated strings pointed to by those pointers).
On the other hand, there is an overload of operator +=
(as well as of operator +
) that takes a CString
and a const char*
, which is why the second example compiles. For the same reason, this would also work:
CString filePath = theApp->GetSystemPath() + CString("test.bmp");
As well as this:
CString filePath = CString(theApp->GetSystemPath()) + "test.bmp";