Ex 42: Is-a, has-a examples

So I was drillling the is-a has-a stuff (and still am) but there’s one thing I’m not entirely sure about because it’s not explicitly covered in the examples…

From ex 42 we know that

foo = Bar()

means “set foo to an instance of class Bar”

and we know that

class Bar(Thing):

means “Make a class Bar that is-a Thing”

But what of this?

foo = Bar(thing)

Would that be “set foo to an instance of class Bar that is-a thing”?

or would it be “set foo to an instance of class Bar that takes parameter thing”?

Or something else? I’m not clear on this point…

Set foo to an instance of class Bar and initialize it with the argument thing.

1 Like
A free service run by Zed A. Shaw for learncodethehardway.org.