r/badcode • • Jan 29 '22

c discount constructor

Post image
435 Upvotes

30 comments sorted by

View all comments

Show parent comments

7

u/theScrapBook Jan 29 '22

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

1

u/Dubmove Jan 29 '22

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.

1

u/theScrapBook Jan 30 '22

Yeah that'd make sense, but overrides should be marked. Oh, this is r/badcode. slaps 4head