Sayyiduna Abu Hurayrah رضى الله تعالى عنه narrates: Verily the Messenger of Allah (peace be upon him) said: When a person passes away, his deeds come to an end, except for three:
1. Continuous charity
2. Such knowledge, from which benefit is derived
3. A righteous child, who supplicates for him
(Muslim)
A Masjid, Madrasah, well, borehole, etc etc, are means of reaping continuous rewards, as long as it exists.
Knowledge imparted to others, who practice upon it, and he passes it to others, who practice upon it, is a means of continuous rewards for everyone in the chain of knowledge.
A righteous Muslim child’s good deeds, will be a source of reward for the parents. Parents are encouraged to guide their children, towards righteousness, so that they can gain maximum benefit, when they are most in need of it.