vs2005 include <iostream>之后为什么还提示cout为定义?
studio吧
全部回复
仅看楼主
level 2
cacer 楼主
//LinkQueue operation
//This program is to initialize, Insert, Delete LinkQueue
#include <malloc.h>
#include <iostream>
#include <conio.h>
# define OK 1
# define ERROR 0
typedef int QElemType;
typedef struct QNode //define structure QNode
{ QElemType data;
struct QNode *next;
}QNode,*QueuePtr;
typedef struct //define structure LinkQueue
{ QueuePtr rear;
}LinkQueue;
int InitQueue(LinkQueue &Q) //InitQueue() suvb-function
{ Q.rear=(QueuePtr)malloc(sizeof(QNode));
if(!Q.rear)
{ cout<<endl<<"Overflow !";
return (ERROR);
}
Q.rear->next=Q.rear;
return (OK);
} //InitQueue() end
int Insert(LinkQueue &Q,QElemType x) //EnQueue() sub-function
{ QNode *p;
p=(QueuePtr)malloc(sizeof(QNode));
if(!p)
{ cout<<endl<<"Overflow !";
return (ERROR);
}
p->data=x;
p->next=Q.rear->next;
Q.rear->next=p;
Q.rear=p;
return (OK);
} //Insert() end
int Delete(LinkQueue &Q,QElemType &x) //Delete() sub-function
{ QNode *q,*p;
if(Q.rear->next==Q.rear)
{ cout<<"Empty! Can't delete!";
return (ERROR);
}
else
{ p=Q.rear->next;
x=p->next->data;
q=p->next;
p->next=p->next->next;
}
free(q);
return (OK);
} //Delete() end
void main() //main() function
{ int j;
QElemType x=1;
LinkQueue Q;
QNode *p;
InitQueue(Q);
cout<<endl<<endl<<"LinkQueue Operation";
cout<<endl<<"==================="<<endl<<endl;
while(x)
{ cout<<"Please input an integar (eg,58; 0 for exit): ";
cin>>x;
Insert(Q,x); //call Insert()
}
Delete(Q,x); //call Delete()
cout<<endl<<"The first element of LinkQueue is: "<<x;
cout<<endl<<endl<<"...OK!...";
getch();
} //main()
错误 1 error C2065: 'cout' : undeclared identifier c:\documents and settings\administrator\my documents\严蔚敏数据结构可执行代码\源程序\第三章\linkqueue.cpp 23

2011年10月19日 13点10分 1
level 1
预编译命令的下一行加上一句
using namespace std;
或者
在使用cout的时候采用std::cout形式
不然系统不知道你用的cout是哪个命名空间里的
2012年07月10日 02点07分 2
1