I was thinking about something that I never understood when I took my QM course. If I have an infinite square well, say $V=0$ for $ -a<x<a$ and $V= \infty$ otherwise.
In the region of interest, the Schrödinger Equation reads:
$$-\frac{\hbar}{2m}\frac{\partial^2\psi}{\partial x^2}=E\psi $$

so the differential equation to solve is:

$$\frac{\partial^2\psi}{\partial x^2}=-k^2\psi$$
with $k^2=\frac{2mE}{\hbar^2}$, as usual. Here, I remember that I was taught that we use the solutions 
$$\psi=A\sin(kx)+B\cos(kx),$$
which obviously satisfies the DE. However, I never quite understood why we don't pick 
$$\psi=Ae^{ikx}+Be^{-ikx},$$ 
since this function also would satisfy the DE.

During my QM course I always struggled choosing when to use an exponential solution versus a sinusoidal one. Could someone shed some light on this matter? There must be a clear reason to choose one over the other when facing a new problem.