An animal's choice of mating partner can be influenced by what it eats during its sexual development, a study of insects has shown.