composition of continuous functions I was wondering if a function $f:[a,b]\rightarrow[c,d]$ is continuous, $g:[c,d]\rightarrow\mathbb{R}$ is continuous, does it necessarily imply that $g\circ f$ is continuous? Are there counterexamples? What is the necessary and sufficient condition for $g\circ f$ to be continuous?
This is not HWQ. I am just wondering if that is possible.

With the sequence definition of continuity it is obvious that $g\circ f$ is continous, because 
$$\lim_{n\rightarrow \infty} g(f(x_n))=g(\lim_{n\rightarrow \infty} f(x_n)) = g(f(\lim_{n\rightarrow \infty} x_n))$$
because $f$ and $g$ are continuous. 
It is hard to say what is necessary that the composition of function is continuous, taking 
$$D(x)=\left\{
\begin{array}{rl}
0 & x\in \mathbb{R}\setminus \mathbb{Q}\\
1 & x \in \mathbb{Q}\\
\end{array}
\right.$$
is discontinuous in every $x\in \mathbb{R}$ but $D(D(x))=1$ is $C^\infty$.
$C^\infty$ means the function is arbitrary often continuous differentiable.
