It works exactly as it should. You're passing month by value, so within renameMonths() "january" is being assigned to a copy. The original object in main() remains the same. To change the original object, you need to pass a reference (or a pointer):
Notice how renameMonths() must dereference the pointer to get to the string, and the call to renameMonths() must pass the address of the object. All of this is hidden from you with references (which are typically implemented as pointers under the hood).
Now, because references are a synonym for an object, there's no way to define a reference to nothing. However, you can have a null pointer that points to nothing. So one reason why a pointer might be used instead of a reference is if you need to represent a nonexistent object.
The left hand side of an expression doesn't carry over, so month == "dec" or "december" is translated as month == "dec" or "december" != 0 . Since "december" is never going to be a null pointer, it's essentially month == "dec" or true , which isn't very helpful. ;) What you really want is month == "dec" or month == "december" . Naturally that should apply to all of your if statements.
It would also be a good idea to use an if..else if..else chain to avoid checking all of the months after a match.
Actually, there is. It's part of the alternative tokens. Though they're not often used, and some compilers (such as Visual C++) disable the keywords by default. As an alternative, <ciso646> defines them as macros rather than keywords.
So it's not "strictly" correct and is loosely defined, but it is part of the standard...?
Um, it's strictly correct and quite well defined. I'm not sure I understand what the problem is here aside from alternative tokens being uncommon (probably because few people know about them) and Microsoft disabling them when extensions are disabled (likely due to a belief that they'll break existing code). Actually, I do understand the problem, but that doesn't spawn entertaining conversation, does it? ;)
Interesting, I've never seen it in anything I've read.
To be fair, the only book I've seen alternative tokens seriously used in is Ray Lischner's Exploring C++.
Admittedly, I haven't read the standard, I don't have a copy of it.
The draft is freely available online, up to date, and sufficiently complete for anyone who's not trying to write a conforming compiler.
>>The draft is freely available online, up to date, and sufficiently complete for anyone who's not trying to write a conforming compiler.
Can you provide a link? I've found several via google, but I'm not sure which would be the most reliable. I would really like to get at that.