  Let $h(-n)$ be the class number of the imaginary quadratic field with
discriminant $-n$. We establish an asymtotic formula for correlations involving
$h(-n)$ and $h(-n-l)$, over fundamental discriminants that avoid the congruence
class $1\pmod{8}$. Our result is uniform in the shift $l$, and the proof uses
an identity of Gauss relating $h(-n)$ to representations of integers as sums of
three squares. We also prove analogous results on correlations involving
$r_Q(n)$, the number of representations of an integer $n$ by an integral
positive definite quadratic form $Q$.
