Any person holding office, whether by election or appointment, who shall, during such person's term of office, accept, hold or retain any other civil office of honor, trust or emolument under the government of the United States, except commissioners for the taking of bail, or of the state, except the office of notary public or commissioner of deeds or officer of the national guard, or who shall hold or accept any other office connected with the government of the city, or who shall accept a seat in the legislature, shall be deemed thereby to have vacated any office held by such person under the city government; except that the mayor may accept, or may in writing authorize any other person holding office to accept, a specified civil office in respect to which no salary or other compensation is provided. No person shall hold two city or county offices, except as expressly provided in this charter or by statute; nor shall any officer under the city government hold or retain an office under a county government, except when such officer holds such office ex officio by virtue of an act of the legislature, and in such case shall draw no salary for such ex officio; provided, however, that any member of the police force or any member of the fire department may hold office as a member of a board of education outside of the city of New York if otherwise qualified to serve thereon.