Cannot use .begin() or .end() on an array

后端 未结 6 1292
陌清茗
陌清茗 2020-12-05 10:01

The error reads:

request for member \'begin\', \'end\' in \'arr\' which is non class type int[5], unable to deduce from expression error.

6条回答
  •  天涯浪人
    2020-12-05 10:26

    Quite late but I think it's worth to mention that:

    void findavgTime(int n)
    {
        int wt1[n];
        fill_wt(wt1,n); //Any method that puts the elements into wt1
        int wt2[3];
        int sum  = accumulate(begin(wt1), end(wt1), 0); // Fails but wt2[3] will pass. Reason: variable-sized array type ‘int [n]’ is not a valid template argument)
    }
    

提交回复
热议问题