The thread was asking why the could produced compilation errors. Turns out that the guy wasn't using a C++11 compiler. Now, I want to ask this:
How can something "obscene" still be considered C++? I mean, if you want to introduce funny changes in the syntax, why not create a new language and call it subjective-C++ or whatever?
And, if each compiler writer wants to have his own rules, might aw well not refer to the language as C++ in the first place!
No, but that is an old C declaration. Probably I should have picked another word. But the thing is that much of the syntax I'm using turns out to be compiler and IDE dependent.
Why would such a small change require a new language to be created ? Think how ridiculous it would sound if someone told you that C++ was created simply to add new syntax for initializing an array in C. Imagine how many variations of C there would be just adding one insignificant feature, I believe this was a problem with C++ before it became standardized.
All languages evolve over time. C++ has undergone tons of changes since its conception. So has C. Python, Java, C#... they all get updated every once in a while. C++ is no different.
I don't know if you've ever seen some old C code, but some of it looked kind of like this:
1 2 3 4 5 6
func(foo, bar)
int foo;
int bar;
{
return foo + bar;
}
That might be considered "obscene" by your standards... but it's just the language's history. It evolves.
No, but that is an old C declaration. Probably I should have picked another word. But the thing is that much of the syntax I'm using turns out to be compiler and IDE dependent.
Code is never dependant on a particular IDE, and compiler dependencies are only there when you use language features not mentioned/declared by the standard (or depend on compiler behavior the standard leaves implementation defined, but you shouldn't do that anyways).
C++11 isn't fully implemented by any compiler that I'm aware of, but all popular C++ compilers support rather large subsets of C++11. For instance, pretty much all of them support the additions to the standard library because they only changed relatively little compared to the ones mentioned in tr1 that has been around for years. I think it's completely safe to make the transition for hobbyists, and I would at least consider it for businesses as well.
I don't know if you've ever seen some old C code, but some of it looked kind of like this:
1 2 3 4 5 6
func(foo, bar)
int foo;
int bar;
{
return foo + bar;
}
I'm speechless :O
Thank you everyone. It's been cleared out now, but what I'm afraid of is that all of a sudden C++ changes to something else, just like C changed to C++. I don't think "changed" is the proper word, but still...
I Don't see how that declaration syntax is, in any way, in any form, any almost synonyme expression, "bad"! Imagine this: vector<int> vec={3, 7, 1, 9, 2, 6, 5, 4, 8}
How would you do it with the old declaration syntax?
1 2 3 4 5 6 7 8 9 10 11 12
vector<int> vec;
for (i=0; i<10; i++)
{
switch (i)
{
case 0:
vec.push_pack(3);
break;
case 1:
//etc...
}
}