I've noticed that a function with a return type of String will also allow returns of const char * as the following code demonstrates:
void setup() {
Serial.begin(250000);
Serial.println(testFunc(true));
Serial.println(testFunc(false));
}
String testFunc(bool retStringType)
{
if(retStringType == true)
{
String s = "String object return type";
return s;
}
else
return("const char * return type");
}
void loop() {
}
It throws no errors or warnings during compilation and works fine. The output when run is:
String object return type
const char * return type
What is the requirement/technique which allows the String class to do this?
I've been trying to search google to figure this out but I can't even figure out what to call this property of a class.