Codomains and the definition of a function A function $f$ is defined as a set of ordered pairs $(x, y)$ such that $(x,b), (x,c) \in f \Longrightarrow b=c$. Since $y$ is determined uniquely by $x$, it is customarily denoted $f(x)$. 
One difficulty I am having with this definition is that it does not specify the codomain. In particular, $f:\mathbb{R} \rightarrow \mathbb{R}_{+}$  such that $f(x)=\exp(x)$ and $g:\mathbb{R} \rightarrow \mathbb{R}$ such that $g(x) = \exp(x)$ would be the same functions under this definition. 
But this is absurd. One is bijective, the other is not.  
 A: Short answer
In set theory, the definition you state is standard. For the rest of mathematics, the appropriate definition is that a function is a triplet $(f,A,B)$ where $f$ is as you state, $A$ is the domain of the relation $f$ and $B$ is a superset of the range of the relation $f$. 
All this is usually implied, unstated and unformalized.
Long answer
In mathematics it sometimes is the case that a certain concept is defined in several different and nonequivalent ways, in different contexts and/or by different people. An example of this is the concept of polynomial (it can be viewed as an infinite sequence, a finite sequence, an expression, etc).
Another example is the concept of function (that is, the intuitive idea of what a function is and how it behaves).
Given a set $G$, abbreviate the property $$\forall (x,y),(x,z)\left((x,y),(x,z)\in G\implies y=z\right)$$ by the "function property".
Set theorists define function as any set or ordered pairs with the function property.
Some algebraists define function as set theorists and others define it as a triplet $(f,A,B)$ where $f$ is a subset of $A\times B$ with the function property such that the domain of $f$ (i.e. the set of the first coordinates of the ordered pairs in $f$) is $A$ and the range of $f$ (i.e. the set of the second coordinates of $f$) is a subset of $B$, ($B$ is called the codomain of $f$). Instead of $(f,A,B)$ it's usual to write $f\colon A\to B$.
Most analysts don't define function at all.
Each person defines function as it fits their needs best. In set theory there's no need for the triplet definition, in Algebra it's more relevant to use the triplet definition. Analysts rarely feel the need to even worry about the details of the definition of function (to the point where, for them, an invertible function is an injective function).
The important thing is that the chosen definition adequately encompasses the concept of function and it serves its purpose in the context it is being used.
What you did in your question was pick a function as envisioned by analyst or algebraist and argue using the definition a set theorist would use. There's no mistake in your reasoning.
If you want to use a definition of function that's suitable for a larger scope of subjects, use the triplet definition (but you'll have little to gain from it in set theory, it will just create chaff).
A: $f$ and $g$ are indeed the same objects, set theoretically. This shows that the codomain is not intrinsic to a function and so neither are notions of surjectivity, etc. But this is fine as long as we specify a codomain; then surjection is well-defined. It is very easy to codify the choice of codomain, just say a function is a subset of $X \times Y \times \{Y\}$... or something.
A: There is no absurdity. The function is the set of pairs, but  saying a function $f:A\to B$ is surjective (bijective) FROM A TO B is not the same as saying $f$ is surjective (bijective), which, when using this def'n of function, is meaningless. In this def'n of a function, care must be taken with the language when speaking of surjective or bijective functions.   
A: Contexts where codomain does not enter into the definition of a map are those in which map composition does not need to be taken into consideration. An object defined this way is often more properly called "graph of a map" or "parameteric set", where such a set is the image set (as in the case of, e.g., parametric surfaces). On the other hand, in map compositions a degree of freedom in the choice of the codomain for the first map is in order for the well-definedness of compositions themselves. So in these contexts, codomain must be an integral part of the map definition.
