Approximation of continuous and discontinuous functions by generalized sampling series