I would like to have a base class that handles the creation of the messagepack so that all the derived classes can use it.
class BaseClass
{
public:
msgpack::sbuffer Pack()
{
msgpack::sbuffer buff;
msgpack::pack(buff, *this);
return buff;
}
};
class DerivedClass: public BaseClass
{
public:
MSGPACK_DEFINE_MAP(message);
private:
std::string message;
};
That way I can do
DerivedClass d;
d.Pack();
I will have several classes all deriving from BaseClass so it would be best to have Pack() in that class. However, when I attempt to do this I get this error:
error: no member named 'msgpack_pack' in 'BaseClass'
Is it possible to put just the call to msgpack::pack in a single function that all the types can use?
I would like to have a base class that handles the creation of the messagepack so that all the derived classes can use it.
That way I can do
I will have several classes all deriving from
BaseClass
so it would be best to havePack()
in that class. However, when I attempt to do this I get this error:Is it possible to put just the call to
msgpack::pack
in a single function that all the types can use?