Why do I get an error about the initializer not being a constant?

后端 未结 6 1641
失恋的感觉
失恋的感觉 2021-01-17 17:49

I am using the following code.

const int X_ORIGIN = 1233086;             
const int Y_ORIGIN = -4728071;              
const int Z_ORIGIN = 4085704;
const in         


        
6条回答
  •  时光说笑
    2021-01-17 18:08

    As an alternative, this would also work in this case:

    enum { X_ORIGIN = 1233086,
           Y_ORIGIN = -4728071,
           Z_ORIGIN = 4085704 };
    
    const int xyzOrigin[] = { X_ORIGIN, Y_ORIGIN, Z_ORIGIN };
    
    int main()
    {
        return 0;
    }
    

提交回复
热议问题