PDA

View Full Version : [ubuntu] [enums] enums error: does not name a type



amreo
28th August 2015, 14:05
I have a c++ class TrisState:


#ifndef TRISSTATE_H
#define TRISSTATE_H

#include <QObject>
#define WIDTH 3
#define HEIGHT 3
class TrisState : public QObject
{
Q_OBJECT
Q_ENUMS(GameState)
public:
explicit TrisState(QObject *parent = 0);
GameState x();

enum GameState {
Player1 = 'X',
Player2 = 'O',
Draw = '-',
Void = ' '
};

private:
GameState board[WIDTH][HEIGHT];

signals:

public slots:

};

#endif // TRISSTATE_H


and


#include "trisstate.h"


TrisState::GameState TrisState::x()
{

}


When i compile the code i've two errors:
trisstate.h:13: error: 'GameState' does not name a type
GameState x();
^

and

trisstate.cpp:4: error: no 'TrisState::GameState TrisState::x()' member function declared in class 'TrisState'
TrisState::GameState TrisState::x()
^

What am i wrong?

ars
28th August 2015, 14:43
Hello,

in the header file first declare the enum before using it:


enum GameState {
Player1 = 'X',
Player2 = 'O',
Draw = '-',
Void = ' '
};

GameState x();


Best regards
ars