错误 1 fatal error C1075: 与左侧的 大括号“{”(位于“d:\visual studio 2008\projects\doublelist\doublelist\doublelist.cpp(6)”)匹配之前遇到文件结束 d:\vis

yao450860487 2008-10-22 06:51:19
// 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????囊个解决呢??

}
...全文
1278 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
帅得不敢出门 2008-10-22
  • 打赏
  • 举报
回复
vc
ctrl+a
然后alt+f8
就会自动缩进的
jianpanlanyue 2008-10-22
  • 打赏
  • 举报
回复
哎呀,发错了;楼主,你仔细看一下,你的class类结构少了 } 。
另外,平时写代码时要注意缩进和匹配,这样的错误就不会犯了,程序读起来也容易。

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧