C++:错误:在“!”之前应为不合格的id代币
C++: error: expected unqualified-id before ‘!’ token
我已经阅读了关于这个主题的大多数相关答案,但我似乎没有发现我的代码有任何错误。以下是我的代码:
一个aborq.cc
...
#include "stdmacro.h"
...
class marker_t {
public:
signed_city_id_t val;
inline marker_t() { val = 0; };
inline signed_city_id_t is_true() { return val; };
inline signed_city_id_t is_false() { return (signed_city_id_t)!val; };
inline void make_true() { val = 1; };
inline void not() { val = (signed_city_id_t)!val; };
};
stdmacro.h
#define LARGE_CITY_ID
...
typedef
#ifdef UNSIGNED_CITY_ID
unsigned
#else
signed
#endif
#ifdef LARGE_CITY_ID
short
#else
char
#endif
city_id_t;
/* signed_city_id_t is the same sizeof() as the city_id_t but can be negative
* and should be asserted not to go more than positive MAX_DEGREE/2
*/
typedef
signed
#ifdef LARGE_CITY_ID
short
#else
char
#endif
signed_city_id_t;
我曾尝试在oneaborq.cc中将"signed_city_id_t"更改为显式的"short"或"int",但这似乎没有帮助。我还尝试将整个类的定义更改为:
class marker_t {
public:
int val;
inline marker_t() { val = 0; };
inline int is_true() { return 0; };
inline int is_false() { return 0; };
inline void make_true() { val = 1; };
inline void not() { val = 0; };
};
即使在整个类定义中没有"!",它仍然会得到相同的错误:"oneaborq.cc:207:错误:在'!'标记之前应为不合格的id"
我正在尝试编译一个TSP(Travelins Salesman Problem)求解器(可在此处找到:http://www.cs.sunysb.edu/~algorith/eimplement/tsp/distrib/tsp_solution),所以如果有人想查看整个源代码,请查看上面的链接。
inline void not() { val = (signed_city_id_t)!val; };
not
类似于C++中的关键字,并且是!
标记的替代拼写。不能将其用作函数的名称。
相关文章:
- 方法内部但循环仍得到预期的不合格id错误C++
- C 预期的不合格ID(类继承)
- 解析问题:预期的不合格的ID和语义问题:C 需要所有声明的类型说明符
- 字符串常量(包括ZenLib/Ztring.h)之前应为不合格id
- Arduino-应为不合格的id
- int之前应为不合格id
- while c++之前应为不合格id
- 预期的不合格id错误,很可能是原因
- 标头C++中应为不合格Id
- 不合格的ID和模板类
- C++中类出现预期的不合格id错误
- QDir目录之前应为不合格的id
- 第25行应为不合格的-id,我该如何更正
- 错误:“int”之前应为不合格的id
- iOS中出现不合格的id错误
- 奇怪的模板错误:应为不合格id
- C++:错误:在“!”之前应为不合格的id代币
- 错误:在if之前需要不合格的id
- 不合格的id错误和井字游戏板不工作
- 在int j之前预期的不合格id.我知道它可能偏离主题,但我找不到错误