没有名称的STL容器数组

C++11 STL container array without a name

本文关键字:数组 STL 有名称      更新时间:2023-10-16

所以我有这个作业要做,我试图处理一个整数数组…我已经给了一些代码写了我的指令,我很困惑,我如何可以处理数组没有名称被传递…我来告诉你我的意思。

给我这个类,我需要写一些成员函数。

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<int,>);

谁能告诉我为什么数组没有名字,或者为什么它不需要名字,或者这只是一个错误?

主要问题是,我试图处理这个数组没有名称,我很困惑。

p。没有时间和老师联系

在函数定义中,您为函数参数指定了一个名称:

void TurtleGraphics::processTurtleMoves(const std::array<int, ARRAY_SIZE> commands)
//                                                                        ^^^^^^^^
{
    // ...
}