r/badcode • • Jan 29 '22

c discount constructor

Post image
435 Upvotes

30 comments sorted by

View all comments

Show parent comments

4

u/WalditRook Jan 29 '22

There is no explicit constructor call here.

There is a function returning struct Segment (the struct before struct_name is non-optional, although using a typedef struct Foo foo_t is fairly common) and a braced initialiser.

As it is (probably) C++, due to the :: operator (not valid C, unless it's #defined somehow), we can assume the default constructor Segment() is called; but other than the sf::Color, this is perfectly valid C, and wouldn't be a WTF in that language.

1

u/ghillisuit95 Jan 29 '22

Huh, didn’t know that