In C++, how to deal with NULL values in a context where we might expect a string or an integer?
Typically, the context would be when retrieving data from a database, e.g. with a LEFT JOIN where some non-existing values in some column would be represented by a NuLL value instead of the expected string or integer.
Strong casting in C++ makes this type of scenario much more difficult to deal with than with PHP.
In PHP, we can easily have a if/else switch using the === operator:
if ($value === NULL) {
// No data.
} else {
// We have some valid data.
}
What would the equivalent look like in C++?
I've searched and couldn't find a C++ relevant question.
The question is valid in general. In my particular case, I am using the dbixx SQL library.