عَنْ أَبِي أُمَامَةَ الْبَاهِلِيِّ رَضِيَ اللَّهُ عَنْهُ قَالَ: سَمِعْتُ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَآلِهِ وَسَلَّمَ يَقُولُ: ((أَرْبَعٌ تَجْرِي عَلَيْهِمْ أُجُورُهُمْ بَعْدَ الْمَوْتِ، رَجُلٌ مَاتَ مُرَابِطًا فِي سَبِيلِ اللَّهِ، وَرَجُلٌ عَلَّمَ عِلْمًا فَأَجْرُهُ يَجْرِي عَلَيْهِ مَا عُمِلَ بِهِ، وَرَجُلٌ أَجْرَى صَدَقَةً فَأَجْرُهَا يَجْرِي عَلَيْهِ مَا جَرَتْ عَلَيْهِ، وَرَجُلٌ تَرَكَ وَلَدًا صَالِحًا يَدْعُو لَهُ))
It is narrated from Sayyiduna Abu Umamah Bahili (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: Four types of people continue to receive reward even after their death: (1) The person who died while guarding in the way of Allah, (2) The person who teaches knowledge to people, so as long as it is acted upon, he will continue to receive reward, (3) The person who gives charity, so as long as people benefit from it, he will continue to receive reward, and (4) The person who leaves behind righteous children who continue to pray for him.