The "auto" variable type bugs me a little bit, since I like C++'s strongly-typed system and being clear on the types of the variables; however, it does make some statements easier to read, I suppose.
Hrm? What's that? I thought C++ was supposed to be source compatible with C. With an auto variable type, it sounds like the following would mean something different:
int main(int argc, char **argv)
{
auto i;
for(i=0; i<argc; i++);
}
C++ is source-compatible with C in that you can compile C code in a C++
app, but necessarily not the other way around. I haven't used the 'auto' keyword in C++ yet, but it sounds like the compiler will infer the variable's type based on what's assigned to it.
Right, and that's NOT what it does in C. This would be a case of legal C code not compiling in C++ (actually, compiling to a different meaning).
I didn't realize an 'auto' keyword had been added to C.. I looked it up
just now, and you're right - it has a differnt meaning. I'm surprised they'd give it a different meaning in both languages. Perhaps someone on the design committee(s) didn't think it out completely..
I didn't realize an 'auto' keyword had been added to C.. I looked it
Well, it was always there, but the only place it's legal, it's also the default, so almost no C code has ever been written that uses the auto keyword.
Regardless, C++ could have used something else to avoid conflict.
Sysop: | Chris Crash |
---|---|
Location: | Huntington Beach, CA. |
Users: | 577 |
Nodes: | 8 (0 / 8) |
Uptime: | 72:43:23 |
Calls: | 10,734 |
Files: | 5 |
Messages: | 442,755 |