how acidified the cheese is is important.
Mutschli, Emmentaler, Gruyere, and Raclette are examples of cheeses that usually melt well because they are low acid and have a decent amount of contained moisture.
Emmentaler and Gruyere when aged longer will not melt as well because they acidify more and this changes the texture.
If a cheese, at least of the alpine type, is soft and flexible it will melt well. If it is hard and crumbly it will not melt so well.