STL list inside of stack

So here is my problem

Write a stack class using two STL lists. Naturally, a single STL list is more than enough to represent a stack.

This is my code so far. I don't know how to implement the push_back, pop front etc. in the list that's inside the stack. Am I even supposed to use templates? I feel like there is an easier way to do this answering the question. Also I am not sure what to do with the other list since it wants two lists. Thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <list>
#include <iostream>
#include <stack>
#include <vector>
using namespace std;

template <typename Object>
class stack{
public:
	void push(Object);
	void pop();
private:
};



int main()
{
	stack<list<int>> test1;
}
Last edited on
if you google 'stack using linked list c++' or 'implement stack using std list' you'll find a lot of info to get you started
I found information on using list for stacks but the problem wants to use STL lists which I couldn't find much info on.
the clue is in the name - STL list is implemented as a doubly linked list. it'd be very rare to find the exact match between your homework and what's out there, you'll have to look, learn and adapt - after all its your homework
if you'd shown a bit more concrete input perhaps it would be easier (more ethical?) to point you in the right direction(s)
Its kind of hard to put more input when you don't know what to input. I wouldn't have asked for help if I could just google
so you're doing a fairly advanced (as far as class-room assignements are concerned) problem and you're saying that you all you could do on your own so far is just jot down the class and method names that you've been supplied with and nothing else??? I'm sorry but I'm not buying that, maybe someone else will ...
Cool, you don't have to. thanks
Topic archived. No new replies allowed.