From the course: C++ Templates and the STL

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Transforming types

Transforming types

- [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…

Contents