Resonant impurity states in quantum-well structures