Whenever a person who has been elected to any office of the State or the counties by the qualified voters of the State shall die while in office and shall leave a spouse surviving, an amount equal to one half of the salary which would have been paid to such person for the unexpired term of such office shall be paid to the surviving spouse from the state or county general fund, as the case may be, in the same manner as previously paid to the person in office.