Help with Stack


I wanted to create a program that loops x's and input to a stack? Why doesn't it work? Please some advise.

Greetings repelsteeltje

#include <iostream>

using namespace std;

template< class T >
class Stack {

private:
int x = 1;
x++;
class = T x;
T x = st;
public:

Stack st [] []() {
push(st);
void st pop;
Push st :: ii.class
void pop :: -ii.class
}

int main();
{

cout << x;
Cout << push(st);

}
You cannot start implementing and initializing stuffs in the class like what you've done. I mean: int x = 1; x++;

Either you do these in a constructor or some other friend function...
hello,

a class is not a function. It tells the compiler how to organize memory.

This implementation needs a lot of work.

I don't want to sound to un-helpful, but its best that a review of class declarations is needed here.

http://www.cplusplus.com/doc/tutorial/classes/

I actually don't have room here to explain how to fix this.
Last edited on
im actually surprised you know what a stack is at this point.
Last edited on
...ROFL...

Really... a semicolon after main along with capital Cout... Nice, but a little too much. Cut it back a little if you want us to believe you really need help.

repelsteeltje wrote:
Why doesn't it work?
Because, you forgot the comments... :)
Topic archived. No new replies allowed.