nullptr with an example in C++

nullptr with an example in C++

nullptr is a keyword introduced in C++11 to replace the ambiguous NULL. It represents a null pointer constant and eliminates overload resolution issues (which were typically just 0 or ((void*)0) in C/C++).

Using NULL or 0 caused ambiguity in overload resolution.

For example: nullptr removes this ambiguity:

func(nullptr);  // Clearly calls func(char*)