C++ C++;11没有名称的STL容器数组

C++ C++;11没有名称的STL容器数组,c++,arrays,stl,C++,Arrays,Stl,所以我有这个家庭作业要做,我正试图处理一个整数数组。。。我收到了我的指令编写的一些代码,我对如何在不传递名称的情况下处理数组感到非常困惑。。。我来告诉你我的意思 我被赋予了这个类,我需要写一些成员函数 class TurtleGraphics { private: const static size_t NROWS = 22; // number of rows in floor const static size_t NCOLS = 70; // number of colums in f

所以我有这个家庭作业要做,我正试图处理一个整数数组。。。我收到了我的指令编写的一些代码,我对如何在不传递名称的情况下处理数组感到非常困惑。。。我来告诉你我的意思

我被赋予了这个类,我需要写一些成员函数

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"    
};
class-TurtleGraphics
{
私人:
const static size\u t NROWS=22;//楼层中的行数
const static size\u t NCOLS=70;//地板中的柱数
const static int start_ROW=0;//海龟将在其中开始的行
const static int start_COL=0;//海龟将从中开始的列
const static int start_DIRECTION=6;//该海龟的方向
//将在开始时面对
//与模拟时钟上的6点钟相同
//其他3个可能值为3、9和12点钟
const static bool start\u PEN\u POSITION=false;//当
//节目开始
//false表示笔直,true表示笔直
void displayFloor()const;//将在屏幕上显示楼层
标准:阵列m_地板;
公众:
常量静态整数数组_SIZE=250;
TurtleGraphics(void);//ctor将初始化所有“false”值,
//以及其他数据成员的初始化
void processTurtleMoves(const std::array);//将处理
//数组“commands”中包含的命令
};
我正在尝试编写void processTurtleMoves(const std::array

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

主要的问题是,我试图在没有名字的情况下处理这个数组,我非常困惑

注:没有时间与讲师联系。

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

void TurtleGraphics::processTurtleMoves(const std::array<int, ARRAY_SIZE> commands)
//                                                                        ^^^^^^^^
{
    // ...
}
void TurtleGraphics::processTurtleMoves(const std::array命令)
//                                                                        ^^^^^^^^
{
// ...
}
在函数定义中,为函数参数指定一个名称:

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

array应该通过const-ref或value进行传递。不相关,但您可能应该通过引用来传递数组。array应该通过const-ref或value进行传递。不相关,但您可能应该通过引用来传递数组。要对@Kerrek的答案展开一点:函数声明(其中没有函数体)参数可以有名称,也可以没有名称,这无关紧要(编译器实际上会忽略它)。定义必须有名称-如果声明和定义之间的名称不匹配,则不会出错。不过,在我看来,最好给参数起个名字(对函数的用户来说可能更容易),最好在声明和定义之间保持名字不变。@Steve:定义也不需要参数名。只有当你想引用参数时才会这样做。在@Kerrek的答案上展开一点:函数声明(在没有函数体的情况下)可以有一个参数名,也可以没有,这无关紧要(编译器实际上会忽略它)。定义必须有名称-如果声明和定义之间的名称不匹配,则不会出错。不过,在我看来,最好给参数起个名字(对函数的用户来说可能更容易),最好在声明和定义之间保持名字不变。@Steve:定义也不需要参数名。仅当您希望引用参数时,它才起作用。