the std::array im getting
no match for ‘operator=’ in ‘myarr = {1, 5, 2, 3, 4}’
error when compiling this code
#include <iostream>
#include <array>
using namespace std;
int main(int argc, char const *argv[])
{
array<int, 5> myarr;
myarr = {1,5,2,3,4};
for(auto i : myarr)
{
cout << i << endl;
}
return 0;
}
but it compiles when i do it on the same line
array<int, 5> myarr = {1,5,2,3,4};
how to assign values on the seprate line
i need to assign values in the class constructor how can i do it ?
class myclass
{
myclass()
{
myarr = {1,2,3,4,5}; /// how to assign it // it gives errors
}
};