哪位高手帮忙看下,怎么会有错呀?
//利用栈实现的迷宫问题非递归解法.cpp
#include <iostream>
#include <iomanip>
using namespace std;
//Stack.h Stack by chain
#ifndef CALCULATOR_HEAD
#define CALCULATOR_HEAD
#include <iostream>
using namespace std;
#endif
struct items
{//栈中三元组结构
int x,y,dir;
};
//////////////////////////////////////////////////////////////////////////
template <class Type>
class Stack; //声明
//////////////////////////////////////////////////////////////////////////
// define stack by chain...
template<class Type>
class StackNode
{// Stack-node by chain
friend Stack<Type>;
private:
Type Data;
StackNode<Type> * link;
StackNode(Type d,StackNode<Type> *l=NULL):Data(d),link(l)
{
}
public:
};
template <class Type>
class Stack
{// Stack by chain
friend ofstream & operator << (ofstream & Out,Stack<Type> StkObj)
{
return Out;
}
private:
StackNode<Type>* top;
public:
Stack():top(NULL) { } //构造函数 ,construct
~Stack();//distruct
bool IsEmpty();//judge whether is a empty stack
void MakeEmpty();//clear stack...
void Push(const Type&item);//压栈
Type Pop();//出栈
Type GetTop();//得栈头结点值
};
////////////////////the member function of class Stack<Type>//////////////////////////////////////////////////////
template <class Type>
bool Stack<Type>::IsEmpty()
{//是空链表栈吗?
return this->top==NULL;
}
template <class Type>
Stack<Type>::~Stack()
{
if (IsEmpty())
return ;
MakeEmpty();
return ;
}
template <class Type>
void Stack<Type>::MakeEmpty()
{//make the chain-stack emty
StackNode<Type> *pTemp=NULL;
if (IsEmpty())
return ;
while (top)
{
pTemp=top->link;
delete top;
top=pTemp;
}
return ;
}
template <class Type>
void Stack<Type>::Push(const Type&item)
{//压栈...
top=new StackNode<Type>(item,top);
return ;
}
template <class Type>
Type Stack<Type>::Pop()
{
StackNode<Type> *pTemp=NULL;
Type RetValue;
pTemp=top;
top=top->link;
RetValue=pTemp->Data;
delete pTemp;
return RetValue;
}
template <class Type>
Type Stack<Type>:: GetTop()
{
return top->Data;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////
//
void main(void)
{
Stack<float> StkObjMaze;//设置工作栈
cout<<StkObjMaze;
}
编译器提示: error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class Stack<struct items>' (or there is no acceptable conversion)