This isn't specific to the real numbers. The domain, range, sum and product could be specified (almost) arbitrarily.
Let $S= f+g$ and $P=fg$. These are continuous functions. $f$ and $g$ are roots of a quadratic equation with continuous coefficients, $z^2 - Sz + P$. There is a formula expressing the solution continuously in terms of $S$ and $P$, using one extraction of a square root.
The only possible source of discontinuity is in the selection of which sign of the square root is used to define $f$ and which one for $g$. To attain discontinuity everywhere, one needs to have $S^2 \neq 4P$ everywhere (so that $f,g$ are always distinct) and for the set where the plus sign is used for determining $f$ to be dense with dense complement. Hence, a splitting of the domain into two dense sets (such as rational and irrational) is not an artificial feature of the answer posted earlier, it is necessary and sufficient for the solution.