编译下面的代码时,我收到以下错误:<错误C2059:语法错误: '常量'>与编译时const int的
3>c:\hedge\hedge\hedge\AisTarget.h(22) : error C2059: syntax error : 'constant'
3>c:\hedge\hedge\hedge\AisTarget.h(22) : error C2238: unexpected token(s) preceding ';'
#if !defined(AisTarget_h)
#define AisTarget_h
#include "GeneralAviationItems.h"
#include <string>
namespace HEDGE {
using namespace GeneralAviation;
class AisTarget : public WaypointLatLon {
public:
static const int NO_DATA = -1000; //here is the error
};
} // end namespace HEDGE
#endif
您的'#if!defined'可以替换为#ifndef'顺便说一句。 – chris 2012-08-02 16:44:05
如果你用'enum {NO_DATA = -1000};'替换'static const int NO_DATA = -1000;''它会起作用吗?在那种情况下,你有一个非常古老的编译器。请不要告诉我们您正在使用Visual Studio 6 ;-) – fredoverflow 2012-08-02 16:44:41
这段代码实际上并不会用于航空,是吗?使用visual studio 2008 express的 – stijn 2012-08-02 16:45:07