You can override base class constructors with a constructor when inheriting a class in almost every OOP language. There is usually some syntax like super(...) or base(...) to call the parent class constructor from the child class
I meant to override seg. For example in the base class might only creates and returns a Segment but inherented classes might have to do some house keeping too.
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.
42
u/low_end_theory310 Jan 29 '22
or an expensive Segment?
13
u/THE-SUBREDDIT Jan 29 '22
Dread. Also something I finally understood cuz I am a noob
11
u/FloweyTheFlower420 sadistic Jan 29 '22
Uses SFML, a C++ programming library... then ignores constructors.
18
u/Dubmove Jan 29 '22
That's not necessarily bad code.
8
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 29 '22
Image Transcription: Code
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
3
u/jniel93 Jan 29 '22
I write colour as well, but I donāt think Iād be able to write āColor colourā
2
u/haykam821 Jan 29 '22
I might be more mad at
sf::Color colour.1
u/Rigatavr Jan 30 '22
discount constructorfactoryFTFY
80
u/[deleted] Jan 29 '22
[removed] ā view removed comment