The teaching is from the Milindapañha.
'Venerable Nāgasena, these givers when they bestow their offerings, devote them specifically to former (relatives) now departed, saying: "May this gift benefit such and such." Now do they (the dead) derive any benefit therefrom?'
'Some do, O king, and some do not.'
'Which then are they that do, and which do not?'
'Those who have been reborn in purgatory, O king, do not; nor those reborn in heaven; nor those reborn as animals. And of those reborn as Pretas three kinds do not: the Vantāsikā (who feed on vomit), the Khuppipāsino (who hunger and thirst.), the Nijjhāmatañhikā (who are consumed by thirst). But the Paradattūpajīvino (who live on the gifts of others) they do derive profit, and those who bear them in remembrance do so too.'
'Then, Nāgasena, offerings given by the givers have run to waste, and are fruitless, since those for whose benefit they are given derive no profit therefrom.'
'No, O king. They run not to waste, neither are fruitless. The givers themselves derive profit from them.'
(Mil. 294-7, Th. Rhys Davids trans.)
For the full dialogue:http://www.sacred-texts.com/bud/sbe36/sbe3606.htm
Khandhānaṃ rāsaṭṭhaṃ, āyatanānaṃ āyatanaṭṭhaṃ,
Dhātūnaṃ suññaṭṭhaṃ, indriyānaṃ adhipatiyaṭṭhaṃ,
Saccānaṃ tathaṭṭhaṃ aviditaṃ karotītipi ‘avijjā’.
It prevents knowing the meaning of heap in the aggregates, the meaning of actuating in the sense-bases, the meaning of voidness in the elements, the meaning of predominance in the faculties, and the meaning of suchness in the truths, thus it is called ‘ignorance’.
(Visuddhimagga XVII. 43)