gpt4 book ai didi

c++ - 诅咒 C++ 类的错误

转载 作者:行者123 更新时间:2023-11-28 08:22:09 27 4
gpt4 key购买 nike

#include <iostream>
#include <conio.h>
#include <vector>
#include <cstdio>
#include "color.h"
#include <curses.h>
using namespace std;
using namespace ConsoleColor;
namespace color = ConsoleColor;

int i, n;
char input, white_space = 250, obstacle_default = 219, player=1, up_key=119, down_key=115, left_key=97, right_key=100;

class box {
int x, y, pos, pos_x, pos_y, area;
vector<int> obstacles;
public:
box (int,int);
void print (void);
void move (void);
void set_obstacles (vector<int> v);
};

int main()
{
box main_hallway(50,10);
vector<int> obstacle_list={1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40};
main_hallway.set_obstacles(obstacle_list);
main_hallway.move();
return 0;
}
[...]

使用上面的代码,在从 pdcurses 库中包含 curses.h 之后,我立即得到这两个错误:

27:错误:应为“;”在“main_hallway”之前
28: 错误:“main_hallway”未在此范围内声明

该代码事先运行良好,但添加了 pdcurses...它似乎不喜欢与类一致。有办法解决这个问题吗?

附加信息:
-- Windows Vista 专业版
-- 代码:: block 10.04+MinGW32
-- PDCurses 3.4

最佳答案

推测,pdcurses 中有一个#define 在这里定义了一些标记。我猜是 move 还是 print。在 WIndows 上使用 cl/e 查看预处理器的结果。

关于c++ - 诅咒 C++ 类的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5413783/

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