#include<iostream>
#include<stdlib.h>
using namespace std;
template<class T, unsigned int ssize =100 >
class StackTepmlate{
T StackTepmlate[ssize];
int top;
public:
StackTepmlate() : top(0){}
void push(const T& i){
if(top >= ssize) cerr <<"Too many push()es\n";
else stack[top++]=i;
}
T pop(){
if(top<=0) cerr<<"Too many pop()s\n";
else return stack[--top];
exit(1);
}
class iterator;
friend class itertor;
class iterator{
StackTepmlate& s;
int index;
public:
iterator(StackTepmlate& st):s(st), index(0){}
iterator(StackTepmlate& st,bool):s(st),index(s.top){}
T operator*() const {return s.stack[index];}
T operator++(){
if(index >= s.top) cerr<<"iterator moved out of range\n";
return s.stack[++index];
exit(1);
}
T operator++(int){
if(index >= s.top) cerr<<"iterator moved out of range\n";
return s.stack[index++];
exit(1);
}
bool operator==(const iterator& rv) const{
return index==rv.index;
}
bool operator!=(const iterator& rv) const{
return index!=rv.index;
}
friend ostream& operator<< (ostream& os, const iterator& it){
return os<<*it; // Line 47 - Intellisense error
}
};
iterator begin(){return iterator(*this);}
iterator end(){return iterator(*this,true);}
};
IntelliSense:多个运营商“&lt;&lt;”匹配这些操作数:第47行
第7行的其他错误:
缺少我让T工作的选项:
谢谢!