You can basically just buy the heirlooms that have useful stats for your class. A thing to note:
Mail with Agility/Intellect and Plate with Strength/Intellect will change the armor type pre level 40
This means for Hunters and Shamans you can buy the Agility-Mail for example. They are Leather under level 40 and turn into Mail automatically once you reach level 40 with your character. (If you send it to another character that's lower than 40 you will get leather again). This of course works the same for Plate wearers.
Heirloom armors like the Agility-Leather however will not turn into mail after level 40.
You also have to know that the main reason why you actually buy heirlooms is not the fact that they scale with level, but rather for the Percentage bonus experience. This means you can also buy a Agility-Leather armor on Hunters or shamans for example. While you can also play with Cloth-Intellect on a warrior during the first few levels if you don't have the plate set, you should definitely switch to normal armor after around level 20 since it would take you too long to kill NPCs after this point.