Q:

Given a pointer p, can you determine whether p points to a valid object? If so, how? If not, why not?

0

Given a pointer p, can you determine whether p points to a valid object? If so, how? If not, why not?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

No, you can't. Because it would be expensive to maintain meta data about what constitutes a valid pointer and what doesn't, and in C++ you don't pay for what you don't want.
However, a *smart pointer* can be used to tell if it points to a valid object.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now