The Medical centre on board ship can stabalise those having a heart attack - and if necessary will get an emergency evacuation by air ambulance to the nearest hospital. 90% of deaths on board ship are caused by heart attacks so if you think you are at risk then I would avoid cruising.
All the bigger ships have medical centres and medical staff onboard. Not sure how well equipped they are to deal with this and I guess it depends on the severity of the attack. Depending on where you are sailing, they will aim to get you ashore if they are unable to deal with. i've certainly seen ambulances meet the ship when we dock before to take off passengers or crew that have medical emergencies that they could not deal with. However if you are in the middle of a transatlantic crossing that may not be so easy to do.
I have even seen a helicoptor land on the ship, we were about 1 hour out of Southampton, all big cruise liners have mortuary's on board.