Interview Questions

C/C++ Questions only (Null Pointers)

C++ programming on UNIX, C++ Networking,C++ Algorithm Questions and Answers


(Continued from previous question...)

C/C++ Questions only (Null Pointers)

1. What is this infamous null pointer, anyway?

2. How do I get a null pointer in my programs?

3. Is the abbreviated pointer comparison ``if(p)'' to test for

non-null pointers valid?

4. What is NULL and how is it #defined?

5. How should NULL be defined on a machine which uses a nonzero bit

pattern as the internal representation of a null pointer?

6. If NULL were defined as ``((char *)0),'' wouldn't that make

function calls which pass an uncast NULL work?

7. If NULL and 0 are equivalent as null pointer constants, which

should I use?

8. But wouldn't it be better to use NULL, in case the value of NULL

changes?

9. I use the preprocessor macro "#define Nullptr(type) (type *)0" to

help me build null pointers of the correct type.

10. This is strange. NULL is guaranteed to be 0, but the null pointer

is not?

11. Why is there so much confusion surrounding null pointers?

12. I'm confused. I just can't understand all this null pointer

stuff.

13. Given all the confusion surrounding null pointers, wouldn't it be

easier simply to require them to be represented internally by zeroes?

14. Seriously, have any actual machines really used nonzero null

pointers?

15. What does a run-time ``null pointer assignment'' error mean?

(Continued on next question...)

Other Interview Questions