用C ++类诅咒错误

时间:2011-03-24 01:37:56

标签: c++ mingw codeblocks

#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 Professional
- Code :: Blocks 10.04 + MinGW32
- PDCurses 3.4

2 个答案:

答案 0 :(得分:1)

Presumable,pdcurses中有一个#define,它定义了一些令牌。我猜是moveprint。在WIndows上使用cl / e来查看预处理器的内容。

答案 1 :(得分:0)

我解决了我的问题,我需要像这样宣布我的课程:

class x {
} y;

而不是:

class x{
};
int main()
{
   x y;
}
相关问题