【发布时间】:2014-03-11 20:35:28
【问题描述】:
所以我有这个作业要做,我正在尝试处理一个整数数组......并且我得到了一些由我的指令编写的代码,我很困惑如何在没有名称的情况下处理一个数组通过...这里我会告诉你我的意思。
我已经获得了这个类,我需要编写一些成员函数。
class TurtleGraphics
{
private:
const static size_t NROWS = 22; // number of rows in floor
const static size_t NCOLS = 70; // number of colums in floor
const static int STARTING_ROW = 0; // row that turtle will start in
const static int STARTING_COL = 0; // column that turtle will start in
const static int STARTING_DIRECTION = 6; // direction that turtle
// will be facing at the start
// 6 as in 6 o'clock on an analog clock
// The other 3 possible values are 3,9 and 12 o'clock
const static bool STARTING_PEN_POSITION = false; // Pen will be up when
// program starts
// false means pen up, true means pen down
void displayFloor() const; // will display floor on the screen
std::array <std::array <bool, NCOLS>, NROWS> m_Floor;
public:
const static int ARRAY_SIZE = 250;
TurtleGraphics(void); //ctor will init. floor to all "false" values,
// as well as initialization of other data members
void processTurtleMoves( const std::array< int, ARRAY_SIZE> ); // will process
// the commands contained in array "commands"
};
我正在尝试编写 void processTurtleMoves(const std::array );
谁能告诉我为什么数组没有名字,或者为什么它不需要名字,或者这只是一个错误?
主要问题是我试图在没有名称的情况下处理这个数组,我很困惑。
PS。没时间联系导师。
【问题讨论】:
-
数组应该通过 const ref 或按值传递。
-
不相关,但您可能应该通过引用传递数组。