(Proof verification) f, g continuous, agree on a dense subset, implies agree on the whole set Exercise 4.6. A subset $S \subseteq X$ is dense in $X$ if $cl(S) = X$. Let $f, g : X → Y$ be continuous.
If $f_{|S} = g_{|S}$ on some dense subset $S$ of $X$ then $f = g$.
I've seem this topic $f,g$ continuous from $X$ to $Y$. if they are agree on a dense set $A$ of $X$ then they agree on $X$ but in my class we have not formaly defined Hausdorff spaces. So I attempt a proof.
Attempted proof:

Proof: Let $f, g: X \rightarrow Y$ be continuous. If $S$ is closed, $cl(S) = X = S$ and $X - S$ = $\emptyset$ so the result follows trivially. Assume that S is not closed. Let $x_0 \in X - S$ such that $f(x_0) \neq g(x_0)$.
Fix $\varepsilon > 0$ small enough such that $|f(x_0) - g(x_0)| > 2\varepsilon$. Then $B_y(f(x), \varepsilon) \bigcap B_y(g(x), \varepsilon) = \emptyset$. Observe that $x_0$ belongs to the pre-images of both balls. Since $f,g$ are continuous, define $\delta := min(\delta_{f}, \delta_{g})$ where $\delta_{f}, \delta_{g}$ are such that
$B_x(x, \delta_{f}) \subseteq f^{-1} B_y(f(x), \varepsilon)$ and $B_x(x, \delta_{g}) \subseteq g^{-1} B_y(g(x), \varepsilon)$.
Since $x \in cl(S)$, we have that $A = (B_x(x, \delta) \bigcap S) \neq \emptyset$. Then $\exists y \in A$ s.t. $f(y) \neq g(y)$. This is a contradiction since $y \in f^{-1} B_y(f(x), \varepsilon)$ and $y \in g^{-1} B_y(g(x), \varepsilon)$ implies that $f(y) \in B_y(f(x), \varepsilon)$ and $g(y) \in B_y(g(x),\varepsilon$), but $f(y) = g(y)$ and these two sets are disjoint.

Is it ok? Anything I could enhance? Language, more straightforwardness?
P.S. "Since $x \in cl(S)$..." in this part I used the property that if $x$ belongs to the closure of a set, then any open ball in $x$ must intersect the set.
Thanks!
 A: Your proof seems fine to me, but this one might be sligthly more straightforward. 
A function is continuous at $c$ if $$\lim_{x \mapsto c} f(x)=f(c).$$ Since both function are continuous and agree on a dense set, it means that there exists a sequence $x_n$ in your dense set where they both agree. Then you get $$f(c) = \lim_{n \to \infty} f(x_n) = \lim_{n \to \infty} g(x_n)=g(c)$$
A: The trouble is, the statement is false in general topological spaces. Let $X=\mathbb R$ with usual topology, $S=\mathbb Q$ and $Y=\{0,1\}$ with indiscrete topology (only $\emptyset$ and $Y$ are open). Then the functions $f(x)=0$, $g(x)=\begin{cases}0&x\in S\\1&x\not\in S\end{cases}$ are both continuous, both agree on $S$, but not on $X$.
So, we need to impose additional criteria (e.g. that the topological space $Y$ is Hausdorff, or, stronger, that it is a metric space). Then you can prove the following (fairly trivial) statement (see: $X$ is Hausdorff if and only if the diagonal of $X\times X$ is closed):

(1) In $Y\times Y$, the diagonal $D_Y=\{(y,y)\mid y\in Y\}$ is closed.

In a metric space, the proof that the diagonal is closed is much easier: note the map $d:Y\times Y\to\mathbb R$ (distance) is continuous, and the diagonal is the pre-image of the closed set $\{0\}$. 
Also, the following is always valid (see: Continuity of cartesian product of functions between topological spaces):

(2) The function $f\times g:X\to Y\times Y$, where we define: $(f\times g)(x)=(f(x), g(x))\in Y\times Y$, is continuous.

Thus, combining (1) and (2): the pre-image of $D_Y$ in $f\times g$ is a closed subset of $X$ containing $S$, so it must contain $\overline{S}=X$.
