gpt4 book ai didi

c++ - 使用 '&'创建成员指针错误

转载 作者:行者123 更新时间:2023-11-28 05:55:39 26 4
gpt4 key购买 nike

<分区>

我正在用 C++ 创建一个游戏并调用了一个函数,但是我收到一条错误消息说我需要插入一个符号来创建一个指向成员的指针。但是,我不确定这需要去哪里......

string MouseAndCatGame::prepareGrid(){
//prepare a string that holds the grid information
ostringstream os;
for (int row(1); row <= SIZE; ++row) //for each row (vertically)
{
for (int col(1); col <= SIZE; ++col) //for each column (horizontally)
{
if ((row == cat_.getY) && (col == cat_.getX))
{
os << cat_.getSymbol(); //show cat
}
else
if ((row == mouse_.getY()) && (col == mouse_.getX()))
os << mouse_.getSymbol(); //show mouse
else
{
bool holePresent(underground_.findHole(col, row));
if (holePresent == true) // If there is a hole at that location
{
os << HOLE; // Show hole symbol
}
else
{
if ((row == nut_.getY()) && (col == nut_.getX()))
{
os << nut_.getSymbol(); //show mouse
}
else
{
os << FREECELL;//show free grid cell
}
}
}
} //end of col-loop
os << endl;
} //end of row-loop
return os.str();
} //end prepareGrid

错误具体如下:Cat::getY':非标准语法;使用 '&' 创建指向成员的指针

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com