From the course: Nail Your C++ Interview
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Vectors in C++ - C++ Tutorial
From the course: Nail Your C++ Interview
Vectors in C++
- [Instructor] Another single data type storage structure, that C++ has is the vector. Like arrays, they can store any data type, but unlike arrays, they can increase or reduce their size dynamically. In C++, the vector is just a template class that contains an array. So as great as they sound, they aren't the most overhead efficient. Vectors, also aren't available in C. So if you are converting from C++ to C, many of the high memory structures are not allowed. A good C++ developer should know how to solve the problem using arrays and vectors in case they ever need to. Let's look at a new problem that would be perfect for a vector. If we have an array with three numbers, and we want to think of these numbers as one, three digit number, then we want to increment by one. For example, if our array contains three, four, five, we would end up with three, four, six. We could create another same size array for the solution,…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.