It is narrated from Sayyiduna Abu Umamah (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "Four kinds of people continue to receive their reward after death: one who dies guarding the frontier in the path of Allah; one who taught some knowledge, whose reward continues for as long as it is acted upon; one who gave some charity, whose reward continues for as long as its benefit continues; and a man who leaves behind a righteous child who supplicates for him."
Hadith Referenceالمعجم الكبير للطبراني / باب الصاد / 7800