Even in ZFC there is no real problem to consider class functions. You need to remember that $f$ is a function if it is a set of ordered pairs, and for every $a\in Dom(f)$ there exists only a unique ordered pair $\langle a,b\rangle\in f$.
This is ultimately what the Replacement axiom schema comes to say (that the image of a function whose domain is a set, is also a set).
Consider the case of ZFC: a class is just a definable predicate. For example, we can use the power set axiom to define the following class: $$C=\{x\mid\exists y. x=P(y)\}$$
This is the class of "all power sets", for example $\{\varnothing\}\in C$, but $\{\{\{\varnothing\}\}\}$ is not in $C$.
Consider the following formula: $$\varphi(z)\iff z=\langle x,y\rangle\land y\in C\land x=P(y)$$ The formula $\varphi$ is true exactly when $z$ is the ordered pair $\langle x,P(x)\rangle$ for some $x\in V$.
Now we can consider the function $P = \{z\mid\varphi(z)\}$, that is $P$ is a function from $V$ into $C$ which gives every set its power set.
It is indeed a function, since every set has a unique power set (it is also injective, but as remarked above - not surjective).
In NBG this is even simpler since classes are actual objects, you just can't have them members of other classes. In here we can define $C\times D$ in the usual way, and declare a function is from a class $C$ into $D$ if its domain is $C$, it has the functionality property, and its range is in $D$.