C++: Adding Iterator Support to our Vector Class
Channel:
Subscribers:
2,650
Published on ● Video Link: https://www.youtube.com/watch?v=JcVgwCtBYKE
Today we wrote a few minor functions to our Vector class (which is fixed at a capacity of 10, unlike a normal vector which will resize its capacity upwards when it fills up), including pop_back, is_empty (a better name than .empty), clear, and most interestingly how to add iterator support to it. Pointers are iterators, so just returning a pointer to the beginning and 1+ the end of arr is all it takes to make .begin() and .end() work, which means our little vector class here works with range-based for loops.
Other Videos By Bill Kerney
2024-02-12 | C++: Debugging Linked Lists using Invariants |
2024-02-09 | Lab Time: Make a Makefile |
2024-02-07 | C++ Linked Lists |
2024-02-05 | C++: Operators and Type Conversion with Constructors |
2024-02-03 | C++ Test Driven Development using Gtest |
2024-02-03 | Managing Computer Science Projects is Hard |
2024-01-31 | Big O Notation |
2024-01-31 | C++ Operators |
2024-01-29 | C++ Timing Code, Benchmarking, UNIX Shell Scripting Automation |
2024-01-26 | Make a Makefile |
2024-01-24 | C++: Adding Iterator Support to our Vector Class |
2024-01-22 | C++ Rule of 3/5 and Vectors |
2024-01-22 | C++ Compiler Flags for Development |
2024-01-17 | Installing a Nerd Font on Windows |
2024-01-17 | Classes in C++ |
2024-01-10 | Review of First Semester C++ |
2023-12-19 | Advent of Code Day 1 (Worked Solution Parts 1 and 2) |
2023-12-19 | Advent of Code Day 16 (Worked Solution for Parts 1 and 2) |
2023-12-01 | Keith: The C++ Mascot |
2023-11-30 | Make a Metahuman Your Avatar |
2023-11-30 | UE5 Level Sequencer: Foosball Time |
Tags:
c++
vector
iterator
range-based for
begin
end
empty
clear
pop_back