Why is `abs()` implemented differently?

You must use std::abs, which has overloads for the primitive types.

You are falling through to the C++ version in one case, and the old C version (which converts its parameters to integral types) in the other.

Things to avoid: (1) using namespace std; (here is why) and (2) not having the appropriate #includes to bring in the functionality you need. Don’t rely on C++ standard library implementations to include files for you implicitly.

Some compilers will warn you of a “lossy” conversion if you set the warning level appropriately.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)