Take an arbitrary category $\mathscr{C}$ and let $A, B \in \text{ob} (\mathscr{C})$. Also, let $\mathscr{C}(A, B)$ the collection of all morphisms between $A$ and $B$. In his book "Basic Category Theory" Tom Leinster writes:
"If $f \in \mathscr{C}(A,B)$, we call $A$ the domain and $B$ the codomain of $f$. Every map in every category has a definite domain and a definite codomain. (If you believe it makes sense to form the intersection of an arbitrary pair of abstract sets, you should add to the definition of category the condition that $\mathscr{C}(A,B) \cap \mathscr{C}(A',B')= \emptyset$ unless $A=A'$ and $B=B'$.)"
My problem is with the statement in between brackets.
The point is that if we work in $\mathbf{Set}$ it seems to me this condition is too strong. Indeed, let a function be defined in such a way that $x \mapsto x^2$ for every $x \in \mathbb{R}$. Then we have actually two morphisms in the category, namely $f \in \mathbf{Set}(\mathbb{R}, \mathbb{R})$ and $f' \in \mathbf{Set}(\mathbb{R}, \mathbb{R}^+)$: the codomains are different but their intersection is nonempty, but $f$ and $f'$ are somewhat similar, i.e., there is some 'overlap' in between them, so we should have something like $\mathbf{Set}(\mathbb{R},\mathbb{R}) \cap \mathbf{Set}(\mathbb{R},\mathbb{R}^+) \neq \emptyset$.
Any help to clarify this point will be greatly appreciated.
Thank you for your time.
In a category the domain and codomain of a morphism are an intrinsic property of a morphism: the same morphism can't have two different domains or two different codomains. In the category of sets, you have to represent a morphism as something like a triple $(X, f, Y)$, where $X$ and $Y$ are sets and $f$ is a set of pairs comprising a function from $X$ to $Y$. In your example you have $(\Bbb{R}, f, \Bbb{R}) \in {\cal C}(\Bbb{R}, \Bbb{R})$ which is not the same as $(\Bbb{R}, f, \Bbb{R}^{+}) \in {\cal C}(\Bbb{R}, \Bbb{R}^{+})$.
In the example immediately following the passage that you quote, Leinster states that "a map from $A$ to $B$ in the category $\mathbf{Set}$ is exactly what is ordinarily called a map (or mapping or function)". This is rather misleading to anyone brought up on the usual set-theoretic definition of a function as a set of pairs.