Need help displaying a stack

So far I have

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47


#include<iostream>
#include <stack>
#include <list> 
using namespace std;

int main()
{
	stack<int, list<int> > stck;

	

	//push the even values 2-10 onto the stack

	stck.push(2);
	
	stck.push(4);
	
	stck.push(6);
	
	stck.push(8);
	
	stck.push(10);

	//display the value at the top of the stack

	cout<<"List Elements: ";
	for(stck = list.begin(); stck != list.end(); stck++)
    cout<<*stck<<" ";


	//pop two values off of the stack

	stck.pop();
	stck.pop();


	//display the new top of the stack

	cout<<"List Elements: ";
	for(stck = list.begin(); stck != list.end(); stck++)
    cout<<*stck<<" ";


	return 0;
}



My problem seems to be in displaying my stack. Can anyone help me with my loop?

Any help and criticism will be welcomed and appreciated, thank you!
If all you want to do is display the top of the stack you can use the top() function.

std::cout << stck.top();
Thank you sir.
You have helped me plenty today. It honestly seems simple in retrospect, but like I said, this is one of the final sections of the semester and is not included in the book, just through vague powerpoints.
Topic archived. No new replies allowed.