Learn how the result of a transformation need not be the same type as the source containers. This example transforms numbers into words.
- [Bill] The transform function is capable of transforming…from one type to another type.…In this example, we'll transform a vector of integers…into a vector of strings.…Here, I have a working copy of numword-transform.cpp,…along with the numword class in numword.h and numword.cpp…all from chapter four of the exercise files.…Numword is a class that I wrote many years ago.…It's part of an exercise I give myself…whenever I learn a new language,…and I have versions of it in C, C++, Plural, Python,…many other languages that I've used over the years.…
Numword very simply converts numbers into words,…and you see here the header file is mostly these constants…that contain the words for the numbers, and the class…is mostly this…words function, which actually converts…the numbers into words.…You're welcome to look through this, use it,…and learn from it, and modify it,…and make it your own.…
Or, and I would certainly recommend this,…take the time after you have completed…this triptych of courses, and write your own,…and then, compare and see how you did things differently…
- Template fundamentals
- STL containers
- Accessing iterators
- Output, forward, and bidirectional iterators
- The transform function
- Transforming strings and types
- Arithmetic, relational, and logical functions
- STL algorithms
Skill Level Intermediate
2. STL Containers
3. STL Iterators
5. STL Functions
6. STL Algorithm
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.