Suppose $X$ is a discrete random variable. Now, if some function $g(X)$ is a measurable function, then $g(X)$ is also a discrete random variable. In this case, we define the Expectation of the discrete random variable $g(X)$ in terms of $p_X(x)$ as $$ E[g(X)] = \sum_{x : p_X(x) > 0} x \cdot p_X(x)$$
Suppose $X$ is a continuous random variable. Now, if some continuous function $g(X)$ is a measurable function, then $g(X)$ is also a continuous random variable. In this case, we define the Expectation of the continuous random variable $g(X)$ in terms of $f_X(x)$ as $$ E[g(X)] = \int_{-\infty}^{+\infty} x \cdot f_X(x) dx$$
Now, suppose $X$ is a continuous random variable and if a function $g(X)$ is a measurable function, then $g(X)$ is also a random variable. If $g(\cdot)$ is a discrete function i.e. if $g(X)$ is a discrete random variable, then how is expectation of $g(X)$ defined in terms of $f_X(x)$?