Since float is a simple data type and is essentially returned in the registers, the "const float" as a return type is not needed, and should be just "float"... the correct format is:

float getDensity() const { return _density; };

We only use the "const Type&" format in cases of complex (usually a class instance) object to a member variable of a class.