why can’t I use pLast to access a field of the Data class via operator ->.
template<typename _Ty> class Data { public: Data(_Ty _data) : pNext(nullptr), pPrev(nullptr), data(_data) {}; ~Data() {}; private: _Ty data; std::unique_ptr<Data> pNext; std::unique_ptr<Data> pPrev; }; template<class _Ty> class queue { public: queue() : pFirst(nullptr), pLast(nullptr) {}; ~queue() {}; bool isEmpty() { return pFirst == nullptr; }; void push_back(_Ty value) { std::shared_ptr<Data<_Ty>> pData = std::make_shared<Data>(value); if (isEmpty()) { pFirst = pData; pLast = pData; return; } pLast = pData; } public: static int count; public: std::shared_ptr<Data<_Ty>> pFirst; std::shared_ptr<Data<_Ty>> pLast; };
I can access a field of the Data class only if my pLast is a regular pointer and not shared or unique. but I need something that I can access through a smart pointer