Architecture for messaging library C++

I have a library, which sends and receives a set of messages and parses them.

So far I’ve used inheritance for my design, i.e.

class BaseMsg {}; class MsgA : public BaseMsg {}; class MsgB : public BaseMsg {}; // etc 

This works quite well, but when using the library I end up casting a lot from the base class to a specific sub class.

So I wondered, if there is a better design.

This is for C++, but probably applies to other object-oriented languages as well.