C++: include <cmath> for NAN.
C++: use constructors for default argument declarations.