What should I do with a test and train set not having same classes?
Well, what you should do depends highly on what your goal here is.
Do you - for whatever reason - have to use the given test and training sets as such?
If not, a valid approach would be to shuffle the available data and determine a new test and training set, so that they each contain all classes.
Do you want a classifier only for d and e, and have to use the given test and training sets?
Then nothing really speaks against just training on the training set with all classes and testing only the ones you are interested in/ have test data for. Of course, then you can not make statements about the accuracy for other classes.
You could also try removing the other classes from the training set, if they won't appear in your application, which may or may not make the classifier perform better on the test data.
Essentially, it's not easy to provide a ceratin answer without having more context about why you have this kind of data, and what your goal is.
It would be great if you can provide a few more details, so we can work on a more fitting answer.