gpt4 book ai didi

C++:错误:在 ‘!’ token 之前需要不合格的 ID

转载 作者:太空宇宙 更新时间:2023-11-04 16:29:03 24 4
gpt4 key购买 nike

我已经阅读了关于该主题的大部分相关答案,但我似乎找不到我的代码有任何问题。下面是我的代码:

oneaborq.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; };
};

标准宏.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: 错误:在‘!’ token 之前需要不合格的 id”

我正在尝试在 OS X 上编译 TSP(Travelins 推销员问题)求解器(可在此处找到:http://www.cs.sunysb.edu/~algorith/implement/tsp/distrib/tsp_solve),所以如果有人想查看完整的源代码,请查看上面的链接。

最佳答案

inline void not() { val = (signed_city_id_t)!val; };

not 类似于 C++ 中的关键字,是 ! 标记的替代拼写。您不能将它用作函数的名称。

关于C++:错误:在 ‘!’ token 之前需要不合格的 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9057543/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com