Quote:strings.cpp: In function ‘std::string tolower(const std::string&)’:
strings.cpp:51: error: ‘transform’ was not declared in this scope
strings.cpp: In function ‘std::string tocapitals(const std::string&)’:
strings.cpp:85: error: ‘transform’ was not declared in this scope
I assume this has something to do with ctype.h?
<snip>
Would there have been a more logical way to solve this problem? As I might not always have internet access, I'd like to be more self sufficient as opposed to relying on google and your brains for answers.
That was the correct solution. When something in a standard library isn't found, there's a 99.9% chance that the header file wasn't included. Things were moved around in various releases of the STL, different compiler versions, and different implementations handle things differently, which is why this code compiled for Nick but didn't compile for you.
Quote: Also, I noticed the STL includes toupper() and tolower() functions, so I thought you'd be able to just call that with arguments, but you've implemented your own functions tolower() and tocapitals(), using the transform() function. Is this correct, and if so, why?
I think you probably mean the standard C library, not the STL itself. The toupper and tolower functions work on one character at a time. Therefore, to work on an entire string, you transform each character of the string (one character at a time) by passing it through the appropriate function. |