C++
C++
2. Iterators
Used to point to container elements. Types:
o input_iterator, output_iterator, forward_iterator,
bidirectional_iterator, random_access_iterator
3. Algorithms
Operate on containers using iterators.
Examples: sort(), find(), count(), reverse(), accumulate(), binary_search()
4. Function Objects & Utilities
pair, tuple, bind, function, lambda, etc.
int main() {
vector<int> dogAges = {3, 1, 5, 2, 4};
sort(dogAges.begin(), dogAges.end());
for (int age : dogAges) cout << age << " ";
return 0;
}
Expected Output:
12345
int main() {
map<string, int> items = {{"apple", 50}, {"banana", 30}, {"milk", 70}};
for (auto it : items)
cout << it.first << ": " << it.second << endl;
return 0;
}
Expected Output:
apple: 50
banana: 30
milk: 70
int main() {
set<string> destinations = {"Paris", "London", "New York", "Paris"};
for (const auto& city : destinations)
cout << city << endl;
return 0;
}
Expected Output:
London
New York
Paris
🔜 Next Steps
I’ll now create:
50 scenario-based questions like the above
For each: STL used, syntax/methods, expected results
Would you like me to prepare:
A downloadable Word/PDF file with all 50?
Or should I start listing the next 10 here for review before continuing with
the rest?
Let me know how you'd like to proceed.