That's why this is a team game. If you're in a squad of four, and there's no Engineer for example, it would be a prudent decision to spawn as Engineer in case hey, look, tank incoming. Teamwork is always the name of the game in Battlefield, nobody gives a fuck about your K/D score. If a tank kills you, spawn with a kit that can take it out, and always assume that nobody else on your team is going to do it - if someone does, all the power to your team; if nobody does, then you're a goddamn hero. Worse comes to worst, just run and hide.
Other than the Recon, all the classes can take out a tank with concentration and a little luck - Assault's M320 can take one out with enough ammo, Support has C4, Engineer has, of course, everything - RPG, AT Mine, Javelin, hell even the fucking blowtorch does good damage to vehicles if you're shit out of options. Recon is good for indirectly taking it out by laser-spotting with the SOFLAM to turn any tank into a death-trap if you've got an Engy with a Jav nearby, or a friendly tank with Guided Shells, amongst other things.