Definition of the $\mathrm{hom}$ functor in category theory

I am going through some notes Physics, Topology, Logic and Computation: A Rosetta Stone, on category theory.

We first define the opposite category:

Given a category $C$, we define the opposite category $C^{op}$ as the category with the same objects as $C$, but a morphism $f:X\rightarrow Y$ in $C^{op}$ is a morphism $f:Y\rightarrow X$ in C, and the composition $gf$ in $C^{op}$ is the composite $fg$ in $C$.

We then define the hom functor:

For any category $C$, the hom functor $$\mathrm{hom}:C^{op}\times C\rightarrow \mathrm{Set}$$ sends any object $(X,Y)\in C^{op}\times C$ to the set $\mathrm{hom}(X,Y)$, and sends any morphism $(f,g)\in C^{op}\times C$ to the function $$\mathrm{hom}(f,g):\mathrm{hom}(X,Y)\rightarrow \mathrm{hom}(X',Y')$$ $$h\rightarrow ghf$$ when $f:X'\rightarrow X$ and $g:Y\rightarrow Y'$ are morphisms in $C$.

My question is, how is $\mathrm{hom}$ a functor? If $f$ maps from $X'\rightarrow X$ and $g$ from $Y\rightarrow Y'$, then shouldn't $\mathrm{hom}(f,g)$ map from $\mathrm{hom}(X',Y)$ to $\mathrm{hom}(X,Y')$? At first I thought this was a typo, but I can't seem to make it work if I switch round $X$ and $X'$.

A morphism from $(X,Y)$ to $(X',Y')$ in $C^{op}\times C$ consists of a morphism $X\to X'$ in $C^{op}$ and a morphism $Y\to Y'$ in $C$, which is the same as a morphism $X'\to X$ in $C$ and a morphism $Y\to Y'$ in $C$. So when they write that $f:X'\to X$, they are thinking of $f$ as a morphism in $C$, rather than $C^{op}$; in $C^{op}$, $f$ is going the expected direction $X\to X'$. When they write $ghf$, they are also computing this composition in $C$ (and you can check that this composition makes sense: in $C$, you have $X'\stackrel{f}\to X\stackrel{h}\to Y\stackrel{h}\to Y'$, so the composition is defined and is a map $X'\to Y'$).
Choose some $h \in \hom(X,Y)$. Then we have functions $f:X' \to X$, $h:X \to Y$, and $g:Y \to Y'$, so the composition $ghf$ maps $X' \to Y'$. Therefore $ghf \in \hom(X',Y')$.
So we have a rule that starts with any morphism $h \in \hom(X,Y)$ and builds from it a morphism $ghf \in \hom(X',Y')$. That means we have a mapping $\hom(X,Y) \to \hom(X',Y')$.