回复 10楼 TonyDeng
按照您说的方式报错确实减少了很多,但是出现了这样的报错,真的觉得很抱歉,但是不得不再打扰您error C2059: 语法错误 : “namespace”
1>d:\我的文档\visual studio 2008\projects\bishe\bishe\init.cpp(5) : error C2238: 意外的标记位于“;”之前
1>d:\我的文档\visual studio 2008\projects\bishe\bishe\init.cpp(70) : fatal error C1075: 与左侧的 大括号“{”(位于“d:\我的文档\visual studio 2008\projects\bishe\bishe\tools.h(2)”)匹配之前遇到文件结束
这个是Queue类的源文件
#include"stdafx.h"
#include"tools.h"
using namespace std;
Queue::Queue(int size)
{
maxsize=size;
q=new int[maxsize];
front=0;
rear=0;
i=0;
n=0;
}
void Queue::Add(int &x)
{
q[i]=x;
rear=rear+1;
if(i<(maxsize-1))
i++;
else
i=0;
}
void Queue::Delete()
{
front=front+1;
q[n]=0;
if(n<(maxsize-1))
n++;
else
n=0;
}
bool Queue::Search(int &x)
{
int k;
for(k=0;k<maxsize;k++)
{
if(q[k]==x)
{
return 1;
break;
}
else
return 0;
}
}
Queue::~Queue()
{
delete q;
}
这个是Gate类的源文件
#include"stdafx.h"
#include"tools.h"
using namespace std;
Gate::Gate(int inNo1, int ioutNo){
InStr1_No=inNo1;
OutNo=ioutNo;
InStr1_CC0=InStr1_CC1=(InStr1_No<0)?1:1*10^7;
OutNo=OutNewCCO=OutNewCC1=OutOldCCO=OutOldCC1=1*10^7;
Pnext1=Pnext2=Pnext3=NULL;
InStr2_No=InStr3_No=-1*10^7;
}
Gate::Gate(int inNo1, int inNo2, int ioutNo){
InStr1_No=inNo1;
InStr2_No=inNo2;
OutNo=ioutNo;
InStr1_CC0=InStr1_CC1=(InStr1_No<0)?1:1*10^7;
InStr2_CC0=InStr2_CC1=(InStr2_No<0)?1:1*10^7;
OutNo=OutNewCCO=OutNewCC1=OutOldCCO=OutOldCC1=1*10^7;
Pnext1=Pnext2=Pnext3=NULL;
InStr3_No=-1*10^7;
}
Gate::Gate(int inNo1, int inNo2,int inNo3, int ioutNo){
InStr1_No=inNo1;
InStr2_No=inNo2;
InStr3_No=inNo3;
OutNo=ioutNo;
InStr1_CC0=InStr1_CC1=(InStr1_No<0)?1:1*10^7;
InStr2_CC0=InStr2_CC1=(InStr2_No<0)?1:1*10^7;
InStr3_CC0=InStr3_CC1=(InStr3_No<0)?1:1*10^7;
OutNo=OutNewCCO=OutNewCC1=OutOldCCO=OutOldCC1=1*10^7;
Pnext1=Pnext2=Pnext3=NULL;
}
void Gate::ChangeNextIn()
{
if(Pnext1!=NULL)
{
if(OutNo=Pnext1->InStr1_No){
Pnext1->InStr1_CC0=OutNewCCO;
Pnext1->InStr1_CC1=OutNewCC1;
}
else if(OutNo=Pnext1->InStr2_No){
Pnext1->InStr2_CC0=OutNewCCO;
Pnext1->InStr2_CC1=OutNewCC1;
}
else
{
Pnext1->InStr3_CC0=OutNewCCO;
Pnext1->InStr3_CC1=OutNewCC1;
}
}
if(Pnext2!=NULL)
{
if(OutNo=Pnext2->InStr1_No){
Pnext2->InStr1_CC0=OutNewCCO;
Pnext2->InStr1_CC1=OutNewCC1;
}
else if(OutNo=Pnext2->InStr2_No){
Pnext2->InStr2_CC0=OutNewCCO;
Pnext2->InStr2_CC1=OutNewCC1;
}
else
{
Pnext2->InStr3_CC0=OutNewCCO;
Pnext2->InStr3_CC1=OutNewCC1;
}
}
if(Pnext3!=NULL)
{
if(OutNo=Pnext3->InStr1_No){
Pnext3->InStr1_CC0=OutNewCCO;
Pnext3->InStr1_CC1=OutNewCC1;
}
else if(OutNo=Pnext3->InStr2_No){
Pnext3->InStr2_CC0=OutNewCCO;
Pnext3->InStr2_CC1=OutNewCC1;
}
else
{
Pnext3->InStr3_CC0=OutNewCCO;
Pnext3->InStr3_CC1=OutNewCC1;
}
}
}
void Gate::Push(Queue &qu)
{
if((OutOldCCO!=OutNewCCO)||(OutOldCC1!=OutNewCC1))
{
OutOldCCO=OutNewCCO;
OutOldCC1=OutNewCC1;
if(Pnext1!=NULL)
{
if(~qu.Search(Pnext1->OutNo))
qu.Add(Pnext1->OutNo);
}
if(Pnext2!=NULL)
{
if(~qu.Search(Pnext2->OutNo))
qu.Add(Pnext2->OutNo);
}
if(Pnext3!=NULL)
{
if(~qu.Search(Pnext3->OutNo))
qu.Add(Pnext3->OutNo);
}
}
}
void Gate::add2(int &y, int &x1, int &x2)
{
if((x1<1*10^7)&&(x2<1*10^7))
y=x1+x2+1;
else
y=1*10^7;
}
void Gate::add3(int &y, int &x1, int &x2,int &x3)
{
if((x1<1*10^7)&&(x2<1*10^7)&&(x3<1*10^7))
y=x1+x2+x3+1;
else
y=1*10^7;
}
void Gate::min2(int &y, int x1, int x2)
{
if(x1<x2)
y=x1;
else
y=x2;
if(y<1*10^7)
y=y+1;
}
void Gate::min3(int &y, int &x1, int &x2, int &x3)
{
if((x1<x2)&&(x1<x3))
y=x1;
else
if((x2<x3)&&(x2<x1))
y=x2;
else
y=x3;
if(y<1*10^7)
y=y+1;
}