Theory of the resistivity of heavy-fermion compounds