Why can't I return NULL to a 'const String&' method?
I have the following method declaration: const String&
MyClass::GetAspect(const String& strKey) const
In this method, we've decided to do a null-pointer check before doing some
stuff; if the pointer inside this method is null, we want to just return
null.
However, I get the following error:
myclass.cpp(222) : error C2440: 'return' : cannot convert from 'int' to
'const String &'
Reason: cannot convert from 'int' to 'const String'
No constructor could take the source type, or constructor overload
resolution was ambiguous
Could someone help me understand this? Is there some const-correctness
concept I don't fully understand here?
No comments:
Post a Comment