We introduce the construction of a generalized direct product associated with a graph of groups and prove two sufficient conditions for its existence. These results are applied to obtain some sufficient conditions for an HNN-extension with central associated subgroups to be residually a C-group where C is a root class of groups. In particular, it is proved that an HNN-extension of a solvable group with central associated subgroups is residually solvable.