Learn how STL strings may be used in place of the containers in the transform function. The transformations happen on a character-by-character basis.
- [Narrator] Transforming strings is a bit of…a special case, because strings…are not obviously containers.…The string class however, is a class with an interface…that's compatible with other SDL container classes.…So here I have a working copy of string-transform.cpp.…From chapter four of the exercise files.…Here we have two SDL strings, s1,…and s2.…S1 is a normal string, and s2 is a string…of the same size as s1, that's been filled…with dots, with periods.…
And I could actually…display s2 here as well.…And then there's a transform function.…Which as its fourth argument, as its…transforming operator, uses this toupper function.…You'll notice these scope resolution operator.…This simply distinguishes between the function…and a colon macro, in the standard library so,…when I build and run this,…you see that our transformation…is starting at the beginning, and ending…at the end of string 1, and depositing…the results in string 2.…
String 2 starts out as a string full of periods,…and then it gets transformed to the s1,…
- 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.