The Holy Prophet (peace and blessings be upon him) said, "What is credited to a believer of his action and good deed after his death is any useful knowledge he might have taught or spread, a Allah-fearing child he might have left behind, a copy of the Qur'an he might have left to an heir, a mosque he might have built, a house he might have dedicated for use by travelers, a stream or river he might have caused to run, a donation to charity (i.e. sadaqah) he might have set aside when he was enjoying good health. All that catches up with him after his death." (Ibn Majah)