I need help and badly.
I know ive posted this program before.but im having trouble printing the output in certain lines
12 F:\373\TestProg.cpp no matching function for call to `Stack<int, 100>::Print(int)'
14 F:\373\TestProg.cpp no matching function for call to `Stack<int, 100>::Print(int)'
16 F:\373\TestProg.cpp no matching function for call to `Stack<int, 100>::Print(int)'
18 F:\373\TestProg.cpp no matching function for call to `Stack<int, 100>::Print(int)'
20 F:\373\TestProg.cpp no matching function for call to `Stack<int, 100>::Print(int)'
29 F:\373\TestProg.cpp no matching function for call to `Stack<int, 100>::Print(int&, int)'
51 F:\373\TestProg.cpp no matching function for call to `Stack<int, 100>::Print()'
in my main:
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#include "S_Stack.h"
#include<iostream>
using namespace std;
int main()
{
Stack<int,100>i;
int a;
int x;
i.Push(1);
i.Print(1);
i.Push(2);
i.Print(2);
i.Push(3);
i.Print(3);
i.Push(4);
i.Print(4);
i.Push(5);
i.Print(5);
a=i.TopItem();
cout<<"The top item is "<<a<<endl;
i.Pop(x);
i.Print(x,100)<<endl;
if(i.IsEmpty())
{
cout<<"Stack is empty"<<endl;
}
else
{
cout<<"Stack is not empty"<<endl;
}
if(i.IsFull())
{
cout<<"Stack is full"<<endl;
}
else
{
cout<<"Stack is not full"<<endl;
}
i.clear();
i.Print();
if(i.IsEmpty())
{
cout<<"Stack is empty"<<endl;
}
else
{
cout<<"Stack is not empty"<<endl;
}
system ("pause");
return 0;
}
|
header:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#ifndef S_Stack_h_
#define S_Stack_h_
#include <iostream>
using namespace std;
template<class StackItem,int StackSize>
class Stack
{
private:
StackItem Items[StackSize];
int Top;
public:
Stack(){Top=0;}
void Push(StackItem);
void Pop(StackItem &);
StackItem TopItem();
void Print(ostream&);
bool IsEmpty(){return (Top==0);};
bool IsFull () {return (Top==StackSize);};
void clear();
~Stack();
};
#endif
|
implementation:
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
|
#include "S_Stack.h"
#include<iostream>
using namespace std;
template<class StackItem,int StackSize>
void Stack<StackItem,StackSize>::Push(StackItem x)
{
Items[Top]=x;
Top++;
}
template<class StackItem,int StackSize>
void Stack<StackItem,StackSize>::Pop(StackItem &x)
{
x=Items[Top-1];
Top--;
}
template<class StackItem,int StackSize>
StackItem Stack<StackItem,StackSize>::TopItem()
{
return (Items[Top-1]);
}
template <class StackItem,int StackSize>
void Stack<StackItem,StackSize>::clear()
{
Top=0;
}
template<class StackItem,int StackSize>
Stack<StackItem,StackSize>::~Stack()
{
delete []Items;
}
template <class StackItem,int StackSize>
void Stack<StackItem,StackSize>::Print(ostream& output)
{
StackItem Items;
int Top;
for (int i=0;i<Top;i++)
{
output<<Items[i]<<" ";
}
return output;
}
|
need help ASAP!