结构由于某种原因不能识别成员

Structure not recognizing a member for some reason

本文关键字:成员 识别 不能 由于某种原因 结构      更新时间:2023-10-16

当运行这段代码时,它给了我一个奇怪的错误。我有一个类叫scene, scene有一个数组成员叫"commands"。我有一个结构体cGame,它有一个成员current scene。

struct MainGameLoop{
    void init(){
        this->cGame.init(); 
    }
    game_struct cGame; 
    void begin_cipher(string input){
        if(input == "save" || input == "SAVE"){
            cGame.cPlayer.save_game(); 
            cout << "nnGame saved..."; 
        }
        if(input == "back" || input == "BACK"){
            cGame.go_back();
        }
        if(input != "back" && input != "BACK" && input != "save" && input != "SAVE"){
            bool is_recognized_scene_command; 
            for(int c = 0; c < 11 ; c++){
                if(input == cGame.scene_container[this->cGame.current_scene].commands[c]){
                    cout << "nnREQUEST IS RECOGNIZED BY SCENE...";
                } 
                else{
                    cout << "REQUEST IS NOT RECOGNIZED!"; 
                }
            }
        }
    }
};

下面的代码给出了错误:

279 C:Dev-Cppthe_main_mage.cpp no match for 'operator[]' in '((MainGameLoop*)this)->MainGameLoop::cGame.game_struct::scene_container[((MainGameLoop*)this)->MainGameLoop::cGame.game_struct::current_scene]' 

错误是关于scene_container。你确定这是一个数组/向量/…可以用[]索引吗?current_scene是作为索引的正确类型吗?