为什么我的乘法被当作一个指针

Why is my multiplication being treated like a pointer?

本文关键字:一个 指针 我的 为什么      更新时间:2023-10-16

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相乘是没有意义的。这就是错误告诉你的。