Checkpoint 17.11 Write a statement that defines an empty vector object named ave
ID: 3724101 • Letter: C
Question
Checkpoint 17.11 Write a statement that defines an empty vector object named avect that can 17.12 Write a statement that defines a vector object named avect that can hold ints. 17.13 Write a statement that defines a vector object named avect that can hold ints. 17.14 Write a statement that defines a vector object named vi that can hold ints. The 17.15 What happens when you use an invalid index with the vector class's at() 17.16 What is the difference between the vector class's insert ()member function hold strings. The vector should have ten elements (initialized with the default value 0). The vector should have 100 elements, each initialized with the value 1. vector should be a copy of another vector name v2. member function? and push_back() member function?Explanation / Answer
1)Vector objects holds sting:
std::vector <string> avect;
2)
sytax to store n elements in a vector = vector<int> avect(n,elmenet)
vector holds 10 0's = vector<int> avect(10,0)
3) vector named avect that can hold ints with 100 ones
4) vector object v1 that can holds ints . The vector should copy of another vector v2
5) what happens when we use an invalid index with the vector class's at() member function
It throws an error by showing std::out_of_range
6) Difference between pushback and insert
push_back always puts a new element at the end of the vector
insert allows you to select new element's position
Please do ask me if you have any doubts
1)Vector objects holds sting:
std::vector <string> avect;
2)
sytax to store n elements in a vector = vector<int> avect(n,elmenet)
vector holds 10 0's = vector<int> avect(10,0)
Ans : std::vector<int> vector1(10, 0);
3) vector named avect that can hold ints with 100 ones
Ans : std::vector<int> vector1(100, 1);
4) vector object v1 that can holds ints . The vector should copy of another vector v2
std::vector<int> v1(v2);
5) what happens when we use an invalid index with the vector class's at() member function
It throws an error by showing std::out_of_range
6) Difference between pushback and insert
push_back always puts a new element at the end of the vector
insert allows you to select new element's position
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.