如何解决这个问题呢?
刚得到以下错误:
g ++输出:
duplicate symbol _game in:
/var/folders/w6/yqp0s0t92hl5g842hg8tztfr0000gn/T/main-62666f.o
/var/folders/w6/yqp0s0t92hl5g842hg8tztfr0000gn/T/Game-a5a31d.o
duplicate symbol _game in:
/var/folders/w6/yqp0s0t92hl5g842hg8tztfr0000gn/T/main-62666f.o
/var/folders/w6/yqp0s0t92hl5g842hg8tztfr0000gn/T/Write-83f8ee.o
Run Code Online (Sandbox Code Playgroud)
看来问题不在头文件中。
编辑:头文件看起来像这样:
#ifndef GAME_H
#define GAME_H
#include "Color.h"
#include "Tile.h"
class Game
{
public:
Game();
~Game();
Color getActivePlayer();
void setStarttile(Tile Firststarttile);
Color togglePlayer();
void setRunning(bool run);
char newActiveplayer;
void run();
void runsecondmethod();
private:
Game(const Game &);
Color Activeplayer;
Tile *Starttile;
bool Running;
}game;
#endif
Run Code Online (Sandbox Code Playgroud)