TITLE: Example of a continuous function that don't have a continuous extension
QUESTION [5 upvotes]: Give an example of a topological space $(X,\tau)$, a subset $A\subset X$ that is dense in $X$ (i.e., $\overline{A} = X$), and a continuous function $f:A\to\mathbb{R}$ that cannot be continually extended to $X$, that is, a $f$ for such do not exist a continuous function $g:X\to \mathbb{R}$ such that $f(x) = g(x)$ for all $x\in A$.

I just proved that if $f,g:X\to\mathbb{R}$ are continuous and agree in a dense subset $A\subset X$ then they're equal.
I thought in $X=\mathbb{R}$ with usual topology and $A = \mathbb{R}-\{0\} =:\mathbb{R}^*\ $, so I think $f:\mathbb{R}^*\to\mathbb{R}, f(x) = x^{-1}$ is a continuous function that cannot be continually extended to $\mathbb{R}$. I'm quite sure of this, but I'm stuck in proving it using the definition of continuity in general topological spaces. 
Also, I'm quite confused on how this asked example is not a counterexample of what I proved.
Thanks in advance.

REPLY [2 votes]: Another reason: continuous in the whole line implies locally bounded near every point.
And another counterexample based in a different idea: $\Bbb Q$ is dense in $\Bbb R$ with the usual topology. The function
$$f:\Bbb Q\longrightarrow\Bbb R$$
$$
f(x) =
\begin{cases}
0:& x < \sqrt2,\\
1:& x > \sqrt2,
\end{cases}
$$
is continuous (check it) and can't be extended continuously to $\Bbb R$.