If you already know the number of elements you want to do comparisons on (in my case, 5), is it better to use std::array
or std::vector
?
for(int i=1; i<a.size(); i++)
if(a[0] != a[i]){
std::cout << "One or more elements are not equal" << std::endl;
break;
}
}
and
for(int i=1; i<myvector.size(); i++)
if(myvector[0] != myvector[i]){
std::cout << "One or more elements are not equal" << std::endl;
break;
}
}
The only difference is one uses std::array
and the other uses std::vector
, but is there a reason to use one over the other in this case given you know the specific number of elements?