People with poor heart health are more likely to develop thinking problems than those without heart disease, according to a new study.