// vector::at
#include <iostream>
#include <vector>
int main ()
{
std::vector<int> myvector (10); // 10 zero-initialized ints
// assign some values:
for (unsigned i=0; i<myvector.size(); i++)
myvector.at(i)=i;
std::cout << "myvector contains:";
for (unsigned i=0; i<myvector.size(); i++)
std::cout << ' ' << myvector.at(i);
std::cout << '
';
return 0;
}
// vector::at
//from: https://www.cplusplus.com/reference/vector/vector/at/#:~:text=std%3A%3Avector%3A%3Aat&text=Returns%20a%20reference%20to%20the,equal%20to%2C%20its%20size).
#include <iostream>
#include <vector>
int main ()
{
std::vector<int> myvector (10); // 10 zero-initialized ints
// assign some values:
for (unsigned i=0; i<myvector.size(); i++)
myvector.at(i)=i;
std::cout << "myvector contains:";
for (unsigned i=0; i<myvector.size(); i++)
std::cout << ' ' << myvector.at(i);
std::cout << '
';
return 0;
}