They can eat cake if it is not chocolate - but they shouldn't.
The repercussions can be anything from vomiting and diarrhea to pancreatitis - if you give your dog a small piece of cake on a rare occasion it will most likely be fine but I wouldn't recommend it.
Sugar is not good for dogs.