Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
269 views
in Technique[技术] by (71.8m points)

c++ - Initialising a multidimensional array of structs from input function

first post in stack overflow

I'm trying to create a structure where its size is determined by the inputs of the function but i get the errors: error C2131 :expression did not evaluate to a constant failure was caused by a read of a variable outside its lifetime see usage of 'X_Max' and 'Y_Max'

TMap<FVector2D, FVector4> UMaze_Generator::GenerateMaze(const int X_Max,const int Y_Max,int Algorithm_Type)
{   
    struct FBlocks
    {
        //Properties of each block
        int X_Loc;
        int Y_Loc;
        bool bNorth_Wall;
        bool bSouth_Wall;
        bool bWest_Wall;
        bool bEast_Wall;
        bool bStart_Point;
        bool bEnd_Point;
        bool bVisited;
    }Maze[X_Max][Y_Max]; // Error caused by this

I tried searching for an answer but i couldn't find something relatable any ideas what i'm doing wrong here ?

Thanks a lot


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...