【发布时间】:2019-10-17 07:43:52
【问题描述】:
在 Arduino 中使用。问题就在那里:Player::coords[0] = {0, 0};
头文件:
#ifndef game_h
#define game_h
#include <Arduino.h>
class Player {
public:
int getScore();
static int coords[3250][2];
coordinates: x, y
private:
static int score;
};
#endif
Cpp 文件:
#include "game.h"
int Player::score = 1;
int Player::getScore() {
return this->score;
}
int Player::coords[3250][2];
Player::coords[0] = {0, 0};
编译器写道:'class Player' 中的'coords' 没有命名类型
【问题讨论】:
-
你不能在函数之外分配变量。
标签: c++ arrays class static initialization