Here's the problem: I need to implement a stack as an adapter to a List class. I don't know what that means though! I've researched on Google countless times and still don't understand what an adapter is. All the examples I've seen point to using inheritance and then using the inherited functions to perform actions in the adapter class, but I don't know how to do it myself. It just feels wrong that all I'm doing is taking the base class functions and using them for the adapter implementation without the adapter having any original implementation of its own. Can someone help? This is really frustrating me.
greatman05
0
Newbie Poster
Recommended Answers
Jump to PostAn adapter is really nothing more than a wrapper around another class that exposes a specialized interface. So at its simplest, a stack might be implemented like so:
template <typename T> class Stack { public: bool empty() const { return _data.empty(); } void push(T const& x) { …
Jump to PostSo, I understand your code. But, how would I implement the member functions?
By how, I mean do I create my own implementation or use the implementation provided in the adaptee class?You say you understand my code, but your question suggests otherwise. Clearly the member functions are …
All 8 Replies
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
greatman05
0
Newbie Poster
greatman05
0
Newbie Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
greatman05
0
Newbie Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
greatman05
0
Newbie Poster
greatman05
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.