Suppose there are two types of objects A and B and two getter functions
objA* getA(int id) and objB* getB(int id)
Objects A and B are mutually exclusive. that is, if the object is A, then it is not B. When to search for the object using the identifier, the code that I use is given below. So I'm just wondering if the function can return a non-NULL pointer to an object that can point to pattern A or B. Or return null if the identifier is invalid.
void find(int id) { objA* pa = getA(id); if (pa != NULL) { return; } objB* pb = getB(id); if (pb != NULL) { return; } }
source share