c++ - container for derived template classes -
i have next classes:
template <typename t> class packetmember { public: packetmember() { } // non-virtual fellow member functions }; template <typename t> class normalmember : packetmember<t> { public: }; template <typename t> class checksummember : packetmember<t> { public: };
i have std::vector
container containing std::unique_ptr
or std::shared_ptr
. created 1 this:
typedef std::unique_ptr<packetmember<unsigned char> > prt; std::vector<prt> v; v.push_back(prt(new normalmember<unsigned char>(header)));
but compiler complains packetmember<unsigned char>
beingness inaccessible base of operations of normalmember<unsigned char>
. i've seen people suggesting on website utilize poiter / smart-pointer base of operations class , create point derived classes. doing wrong here?
c++ templates inheritance c++11 smart-pointers
No comments:
Post a Comment