错误 1 fatal error C1075: 与左侧的 大括号“{”(位于“d:\visual studio 2008\projects\doublelist\doublelist\doublelist.cpp(6)”)匹配之前遇到文件结束 d:\vis
// doubleList.cpp : 定义控制台应用程序的入口点。
#include"stdafx.h";
template<class T>
class doubleList
{
protected:
struct node
{
T item;
node* prev;
node* next;
}
private:
node* head;
node* last;
long length;
public:
doubleList()
{
head=NULL;
last=NULL;
length=0;
}//default constructor
public:
class iterator
{
friend class doubleList<T>;
protected:
node* nodePtr;
iterator(node* newPtr)
{
nodePtr=newPtr;
}
public:
iterator()
{
}//default constructor
iterator operator++(int)
{
iterator temp;
temp=*this;
nodePtr=(*nodePtr).next;
return temp;
}
iterator operator--(int)
{
iterator temp;
temp=*this;
nodePtr=(*nodePtr).next;
return temp;
}
T operator*()
{
return ((*nodePtr).item);
}
}
iterator begin()
{
return iterator(head);
}//begin
iterator back_begin()
{
return iterator(last);
}
iterator end()
{
return iterator(NULL);
}//end
void push_front(const T &newItem)
{
node* newHead=new node;
newHead->item=newItem;
newHead->next=head;
newhead->prev=NULL;
if(head!=NULL)
{
head->prev=newHead;
head=newHead;
length++;
}
}
void push_back(const T &newItem)
{
node* newLast=new node;
newLast->item=newItem;
newLast->next=NULL;
newLast->prev=last;
if(last!=NULL)
{
last->next=newLast;
last=newLast;
length++;
}
}
void main()
{
doubleList<string> myList;
doubleList<string>::iterator itr;
itr.push_front("enum");
itr.push_front("long");
itr.push_front("string");
itr.push_front("int");
for(itr=myList.begin();itr!=myList.end();itr++)
cout<<"正序输出:"《*itr<<endl;
for(itr=myList.back_begin();itr!=myList.end();itr--)
cout<<"逆序输出:"《*itr<<endl;
Why????囊个解决呢??
}