✅ Inherited a class but the compiler does not accept it?
I've created two classes, Head and Knot. Head inherits Knot with another caveat of having an additional method on it, yet the compiler gives the error of "There is no argument given that corresponds to the required parameter '_coordinate' of 'Knot.Knot(Point)'".
Am I misunderstanding something here?
13 Replies
How many constructors does knot have
one
the constructor is not also inherited?
does head need it's own constructor?
yes
It needs a constructor which calls
: base(Point)
huh...that's interesting...so even though I'm fully inhering from Knot... I still need my own constructor
Yes
I've learned
I mean ya, how would it work otherwise
it inherits Knots constructor? since it's the same object?
and if I need something else, I can override it?
but that's just my poor brain
constructors are not inherited
roger
You are saying "the only way i can build a knot is with this constructor, then inheriting the class and not using that constructor. So there's a world where someone calls
new Head()
Which breaks the assertion that Knot must be created with that constructor
If you added an empty constructor to Knot it would work
In my mind, as, I suspect, in @phattanuki's, I would have imagined that if
Head
doesn't have a constructor defined, it would default to:
(I get that it doesn't, but before I realised that, I felt that this was a reasonable assumption)Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.