c++ - need design help using private inheritance -
i have problem following situation: library (cardreader) implements iso7816 protocol , communicates smart card (implemented me).
i have implement proprietary protocol use library.
in cardreader there following classes apdurequest , apduresponse. , cardreader class implements functions send , receive these messages.
class apduresonse { public: /* ctor, copy ctor, move ctor, copy =, , move = operators. */ //... int statusword() const { return ...; } int sw1() const { return ...; } int sw2() const { return ...; } };
on other hand in software have hierarchy independent implentare messages , smart card. interface of base class:
enum class messagereskind { /* ... */ }; class imessageres { public: virtual ~imessageres() {}; virtual int statusword() const = 0; virtual int sw1() const = 0; virtual int sw2() const = 0; virtual messagereskind kind() const = 0; virtual void print( std::ostream& ) = 0; };
now doubt how derive specialized class... first attempt was:
class admessageresatr : public iadmessageres, private iso7816::apduresponse { public: // import iso7816::apduresponse ctor using iso7816::apduresponse::apduresponse; using iso7816::apduresponse::sw1; using iso7816::apduresponse::sw2; using iso7816::apduresponse::statusword; admessagereskind kind() const { return admessagereskind::atr; } void print() const {} };
but i've compile time error: unable instantiate abstract class admessageresatr: statusword, sw1 , sw2 abstract
not sure trying achieve if want expose interface , use library implementation, can this:
class admessageresatr : public iadmessageres, private iso7816::apduresponse { public: int sw1() const {return iso7816::apduresponse::sw1();} ... };
Comments
Post a Comment