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: | Eric Oulashin |
---|---|
Location: | Beaverton, Oregon, USA |
Users: | 106 |
Nodes: | 16 (1 / 15) |
Uptime: | 03:02:46 |
Calls: | 5,894 |
Calls today: | 10 |
Files: | 8,496 |
D/L today: |
69 files (14,659K bytes) |
Messages: | 344,869 |
Posted today: | 2 |