首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

error C2146: syntax error : missing ';' before identifier 'InitTriplet'错误!

2014-01-28 
我在运行《数据结构算法实现及分析》光盘上的第一章的程序时,就出现了问题了。 我用VC6.0新建了一个win32的空

 我在运行《数据结构算法实现及分析》光盘上的第一章的程序时,就出现了问题了。
我用VC6.0新建了一个win32的空的工程a1,然后将盘上的文件Bo1-1.cpp,Main1-1.cpp,
C1.h和C1-1.h分别都加入到了a1的源文件和头文件中,但是一运行就出现了如下的错误:

f:\algorithm and data structure\bc\ch1\bo1-1.cpp(2) : error C2146: syntax error : missing ';' before identifier 'InitTriplet'
f:\algorithm and data structure\bc\ch1\bo1-1.cpp(2) : error C2501: 'Status' : missing storage-class or type specifiers
f:\algorithm and data structure\bc\ch1\bo1-1.cpp(2) : fatal error C1004: unexpected end of file found

其中,C1.h的代码如下:
#include <string.h>
#include <ctype.h>
#include <malloc.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <math.h>
#include <process.h>
#include <iostream.h>

#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
typedef int Status;
typedef int Boolean;

C1-1.h的代码只有"typedef ElemType *Triplet;"这么一句,

而Bo1-1.cpp中包含的是一些函数的定义,比如:

Status InitTriplet(Triplet &T,ElemType v1,ElemType v2,ElemType v3)
{
if(!(T=(ElemType *)malloc(3*sizeof(ElemType))))
exit(OVERFLOW);
T[0]=v1,T[1]=v2,T[2]=v3;
return OK;
}

Main1-1.cpp是主函数,它包含了:

#include"c1.h"
typedef int ElemType;
#include"c1-1.h"
#include"bo1-1.cpp"
main()
{...}

那么出现上述错误的圆心是什么呢?



------解决方法--------------------------------------------------------
try
在最顶部加入
#include "stdafx.h"
或者编译选项里去掉预编译头文件

        

热点排行