Why are FIND_FROM_ADDR () and find_subject () so different? For example, FIND_FROM_ADDR () returns a bool value, while Find_subject () returns a string. The reason is that we want to explain:
- FIND_FROM_ADDR () should distinguish between two different cases where the address line is empty ("") and no address lines. For the first case, FIND_FROM_ADDR () returns True (because the address row was found) and the S is set to the empty string "" (because the address is empty). For the second case, it should return False (because there is no address line).
- For cases where the subject is empty or there are no subject lines, Find_subject () returns "".
FIND_FROM_ADDR () The distinction between these two situations is meaningful and necessary. When looking for information in a data file, there are frequent nuances of this difference: have we found the domain we want to find? Is the content in this domain useful? In an actual program, FIND_FROM_ADDR () and Find_subject () should be designed in the style of the present find_from_addr () so that the user can differentiate between the differences.
(whether the content exists, whether the content is empty, when to use BOOL (the parameter is a reference, return the content), and when to return the appropriate type)
Principles and Practice of C + + programming (Advanced article)
function return value string differs from return value BOOL------C + + programming principle and practice (Advanced article)