Two molecules (including polyatomic ions) A and B have the same structure if each atom of A can be paired with an atom of B of the same element, in a one-to-one way, so that for every bond in A there is a bond in B, of the same type, between corresponding atoms; and vice versa.  This requirement applies also complex bonds that involve three or more atoms, such as the delocalized bonding in the benzene molecule and other aromatic compounds.
Depending on the context, one may require that each atom be paired with an atom of the same isotope, not just of the same element.
Two molecules then can be said to be structural isomers (or, if isotopes matter, structural isotopomers) if they have the same molecular formula but do not have the same structure.