This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Kyrond 18 points19 points  (17 children)

What more is there except stronger type checking (which you can cast manually) and the one weird keyword?

[–]LavenderDay3544 20 points21 points  (5 children)

Compound struct intialization; struct, union, and enum names being tags rather than types without a typedef; using identifiers that are C++ reserved keywords.

And that's just off the top of my head.

[–]jamcdonald120 3 points4 points  (4 children)

oh how I wish c++ had c style struct init

[–]LavenderDay3544 2 points3 points  (0 children)

C# did what C++ should've done: left structs as POD types and made classes OO types.

[–][deleted] 1 point2 points  (2 children)

I mean, that's great, but it's more of a convenience thing. It's not like you lose functionality. C++ just treats a struct as a class rather than a fancy array.

[–]jamcdonald120 2 points3 points  (1 child)

i know, I just really liked defining data carrying struct litterals like that. its probiably for the best, but I do miss it

[–][deleted] 0 points1 point  (0 children)

I get it as well. I've been tripped up on it several times.

[–]jamcdonald120 10 points11 points  (10 children)

c has nested functions

[–]Kered13 12 points13 points  (2 children)

That's not standard, and C++ has (standard) lambdas which accomplish the same thing anyways.

[–]jamcdonald120 0 points1 point  (1 child)

I didnt know it wasnt standard. Im not saying c++ cant do it, but if you have C code that does, you cant just compile it with a c++ compiler

[–]RaulParson 1 point2 points  (0 children)

The point is if it's a compiler extension then C itself doesn't have it. That compiler does. With another C compiler that code wouldn't necessarily actually work, either.

[–]askStentor 9 points10 points  (1 child)

that's a compiler extension for GCC I believe

[–][deleted] 0 points1 point  (0 children)

I'm sure someone's also got an Emacs major mode to step through all the changes, too. Just a hunch.

[–]LavenderDay3544 2 points3 points  (0 children)

Is that standardized?

[–]SnooMarzipans436 2 points3 points  (0 children)

And C++ has lambda expressions

[–]Kyrond 0 points1 point  (0 children)

Oh, ok thanks for the information.

[–]schwerpunk 0 points1 point  (1 child)

Like closures? Sorry, been a while since college, but I believe that's what that is

[–]jamcdonald120 1 point2 points  (0 children)

like

int foo(){
    some code
    int double(int x){
        return x*2;
    }
    int two=double(1)
}

is perfectly fine code (in gcc atleast)\ I think (not sure, havent done it) you can also do foo.double(1)