为什么我的乘法被当作一个指针
Why is my multiplication being treated like a pointer?
Edit:一个简单的错误,我看了一遍,没有思考。忽略:)
我的代码显示错误:
no match for 'operator*' in 'mapRows * width'
在代码上
// get the current tile number
int tileNumber = levelMap[mapRows*width + currentTile];
申报地点:
for (auto& mapRows : levelMap)
for (auto& currentTile : mapRows) //It loops through the rows, then goes through all the tiles in that column.
{
宽度:
bool Map::load(const std::string& tileset, sf::Vector2u tileSize, unsigned int width, unsigned int height)
和levelMap位于:
std::vector<std::vector<Tile>> levelMap;
抱歉,只是个初学者!
mapRows
似乎是一个std::vector<Tile>
,与int
相乘是没有意义的。这就是错误告诉你的。
相关文章:
- 修改函数中的指针(将另一个指针作为参数传递)
- 将指针分配给另一个指针时会发生什么情况?
- C++将一个指针分配给另一个指针时执行的类型检查
- 更改一个指针后更改乘法对象
- 从另一个指针指向函数的指针
- 有没有办法在同名类 (c++) 中为对象分配一个指针变量
- 为什么通过定义另一个指针单元格,整个代码停止工作?
- C:试图将指针值复制到另一个指针中,得到可修改的左值错误
- C++ typedef 函数指针,并在一个语句中声明一个指针
- 一个对象的两个指针.删除了一个指针,对象仍然存在
- 如何获得GUID编码器,如果我在IMFTransform上有一个指针?
- 我不明白我的错误需要返回一个指针数组
- 使用 SFINAE 测试是否可以将一个指针类型static_cast到另一个指针类型
- 将指针分配给另一个指针时会发生什么情况?
- 如何保存指针地址,以便另一个指针可以继续处理它
- 为什么 std::span 是一个指针 + 大小而不是两个迭代器
- 类的成员应该是一个指针
- 隐式指针变量,在自动定义中具有另一个指针变量
- 利用双重链接列表中的下一个指针
- 你能把一个指针投射到数组中吗?