A study has found that parents with daughters maintain better cognitive function in old age compared to those with only sons.