C++代码练习自写栈类,是我自己写的,出问题解决不了了

#include

#include
using namespace std;
const int Max = 20;
template
class Stack {

public:
T s[Max];
int top;
Stack();
Stack(int)
{

cout << "Constructing" << endl;
top = -1;
}
~Stack()
{
cout << "Destructing" << endl;
delete[]s;
}
void Push(T x);
void Pop(T& x);
bool stackempty();
};

template
bool Stack::stackempty()
{
return top == -1;
}

template
void Stack::Pop(T& x)
{
if (stackempty())
{
cout << "错误!栈空" << endl;
}
else
{
x = s[top];
top--;
}
}

template
void Stack::Push(T x)
{
if (top < Max)
{
top++;
s[top] = x;
}
else
{
cout << "满栈!" << endl;
}
}

int main()
{
Stack s1(4);
memset(s1.s, 0, sizeof(s1.s));
int a, b, c, d;
for(int i=0;i cin >> a >> b >> c >> d;
s1.Push(a); s1.Push(b);
s1.Push(c); s1.Push(d);
int x = 0;
s1.Pop(x);
cout << x << " " << endl;

Stack<char> s2(4);
memset(s2.s, 'a', sizeof(s2.s));
char e, f, g, h;
cin >> e >> f >> g >> h;
s2.Push(e); 
s2.Push(f);
s2.Push(g);
s2.Push(h);
char y = 'a';
s2.Pop(y);
cout << y << " " << endl;
return 0;

}
哪里有问题啊!怎么解决问题啊?

#include

using namespace std;
const int Max = 20;
template
class Stack {

public:
T s[Max];
int top;
Stack();
Stack(int)
{

    cout << "Constructing" << endl;
    top = -1;
}
~Stack()
{
    cout << "Destructing" << endl;
}
void Push(T x);
void Pop(T& x);
bool stackempty();

};
template
bool Stack::stackempty()
{
return top == -1;
}
template
void Stack::Pop(T& x)
{
if (stackempty())
{
cout << "错误!栈空" << endl;
}
else
{
x = s[top];
top--;
}
}
template
void Stack::Push(T x)
{
if (top < Max)
{
top++;
s[top] = x;
}
else
{
cout << "满栈!" << endl;
}
}

int main()
{
Stack s1(4);
memset(s1.s, 0, sizeof(s1.s));
int a, b, c, d;
cin >> a >> b >> c >> d;
s1.Push(a);
s1.Push(b);
s1.Push(c);
s1.Push(d);
int x = 0;
s1.Pop(x);
cout << x << " " << endl;
Stack s2(4);
memset(s2.s, 'a', sizeof(s2.s));
char e, f, g, h;
cin >> e >> f >> g >> h;
s2.Push(e);
s2.Push(f);
s2.Push(g);
s2.Push(h);
char y = 'a';
s2.Pop(y);
cout << y << " " << endl;
return 0;
}

 #include <iostream>

using namespace std;
const int Max = 20;
template <class T>
class Stack {

public:
    T s[Max];
    int top;
    Stack();
    Stack(int)
    {

        cout << "Constructing" << endl;
        top = -1;
    }
    ~Stack()
    {
        cout << "Destructing" << endl;
    }
    void Push(T x);
    void Pop(T& x);
    bool stackempty();
};
template <class T>
bool Stack<T>::stackempty()
{
    return top == -1;
}
template <class T>
void Stack<T>::Pop(T& x)
{
    if (stackempty())
    {
        cout << "错误!栈空" << endl;
    }
    else
    {
        x = s[top];
        top--;
    }
}
template <class T>
void Stack<T>::Push(T x)
{
    if (top < Max)
    {
        top++;
        s[top] = x;
    }
    else
    {
        cout << "满栈!" << endl;
    }
}

int main()
{
    Stack<int> s1(4);
    memset(s1.s, 0, sizeof(s1.s));
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    s1.Push(a); 
    s1.Push(b);
    s1.Push(c); 
    s1.Push(d);
    int x = 0;
    s1.Pop(x);
    cout << x << " " << endl;
    Stack<char> s2(4);
    memset(s2.s, 'a', sizeof(s2.s));
    char e, f, g, h;
    cin >> e >> f >> g >> h;
    s2.Push(e); 
    s2.Push(f);
    s2.Push(g);
    s2.Push(h);
    char y = 'a';
    s2.Pop(y);
    cout << y << " " << endl;
    return 0;
}