As a personal trainer, this is a question I get asked a lot if you are running the best recommendation I can give is to go to a proper running shop and get your gait analysed and they will be able to provide you with the right shoes for how you land.
Some people are more suitable to neutral shoe others need particular trainer if they overpronate (roll inwards) or supinate (overpronate) or you may need a more supportive or stability trainer. The staff will then get you to run in the shoes and look at your gait again and sell you the best trainer for you. Recommendations for changing trainers are every 3-4 months or 500 miles.
Trainers for the gym and classes need to be cushioned and have a sole on them flat canvas type trainers are not suitable, as they are not giving you any support. You need the cushioning and support, as there will be some impact on some exercises that you will do. These trainers need changing every 6-12 months depending on how often you train and the intensity and effect. The best places to buy trainers are from a reputable sports shop always try them on before purchase and ask for trainers suitable for the gym and mention if you use the treadmill, trainer, or high impact classes.