Mike, question not specifically related to the topic of the lesson, rather on how you draw the parent-child relationship. In the first example with inheritance, you've got encircled Character and Point2D, with the arrow pointing towards the parent Point2D. I'm confused why the arrow is pointing this way, for me it looks more logical to point to Character being a child? To my mind, the characteristics of parent are being transferred to the child, not vice versa. What am I missing here? Great job with the series!
In most of the literature that I have seen, the arrow points up from child to parent in regards to inheritance (because you want to know who you inherit from). This is opposite to how we usually draw when first learning about trees for example which is probably the confusion :) Hopefully I did not reverse this in any of the lessons, but again, arrow should point up from child towards parent :)
Hey Mike, thanks for the awesome tutorial! At 6:33, I found that it says that an aggregation can be an array or a class that has no user-declared or inherited constructors (since C++20) ... on cppreference. Is the example at 6:33 still considered to be an aggregation or is this concept still applicable to aggregations? Thanks in advance! The keyword I use in cppreference: Aggregate initialization (It seems like my comment would be deleted by TH-cam if I paste the link)
I think 'aggregate initialization' is more in reference to creating a new object through a mechanism like a list_initializer, versus the general idea of composition (which is about 'holding multiple components/fields/value' -- thus 'aggregating' or collecting one or more different or the same types together). I'll need to think about it a little more, but that's my initial understanding.
Great video and topic too. But could not differentiate between the lifetime of composition against aggregation. Would be appreciated if you could do a pictorial explanation to iron out the lifetime concept. We did aggregation in class using pointer . Why is it called aggregation?
Aggregation is named because we're are 'collecting' or 'making up' a new data type consisting of other types. I agree, a picture may be useful to think about lifetimes. @4:30 I explain a little bit about the subtle difference between composition and aggregation. Composition think about as just having everything being destroyed (on a timeline) with the actual instance of that object. Aggregation could allow other objects to live further on a timeline (e.g. some data being pointed to)
This video reminded me of th-cam.com/video/motLOioLJfg/w-d-xo.html use of composition to delegate methods to references of other class implementations. Your series is my personal prerequisite to reading Klaus's recent book. Thank you so much for this.
As far as I know, composition is a "owns-a" or "is-part-of" relation, while aggregation is "has-a" instead.
Man, you are on a roll Mike!
Thank you for the support! :)
Very neatly explained as always. Thank you.
Cheers, thank you Dhanush!
Composition over inheritance please make a session for this. 😊
Indeed, composition is in favor these days :)
Mike, question not specifically related to the topic of the lesson, rather on how you draw the parent-child relationship. In the first example with inheritance, you've got encircled Character and Point2D, with the arrow pointing towards the parent Point2D. I'm confused why the arrow is pointing this way, for me it looks more logical to point to Character being a child? To my mind, the characteristics of parent are being transferred to the child, not vice versa. What am I missing here? Great job with the series!
In most of the literature that I have seen, the arrow points up from child to parent in regards to inheritance (because you want to know who you inherit from). This is opposite to how we usually draw when first learning about trees for example which is probably the confusion :) Hopefully I did not reverse this in any of the lessons, but again, arrow should point up from child towards parent :)
Hey Mike, thanks for the awesome tutorial! At 6:33, I found that it says that an aggregation can be an array or a class that has no user-declared or inherited constructors (since C++20) ... on cppreference. Is the example at 6:33 still considered to be an aggregation or is this concept still applicable to aggregations?
Thanks in advance!
The keyword I use in cppreference: Aggregate initialization
(It seems like my comment would be deleted by TH-cam if I paste the link)
I think 'aggregate initialization' is more in reference to creating a new object through a mechanism like a list_initializer, versus the general idea of composition (which is about 'holding multiple components/fields/value' -- thus 'aggregating' or collecting one or more different or the same types together). I'll need to think about it a little more, but that's my initial understanding.
Great video and topic too. But could not differentiate between the lifetime of composition against aggregation.
Would be appreciated if you could do a pictorial explanation to iron out the lifetime concept.
We did aggregation in class using pointer . Why is it called aggregation?
Aggregation is named because we're are 'collecting' or 'making up' a new data type consisting of other types. I agree, a picture may be useful to think about lifetimes. @4:30 I explain a little bit about the subtle difference between composition and aggregation. Composition think about as just having everything being destroyed (on a timeline) with the actual instance of that object. Aggregation could allow other objects to live further on a timeline (e.g. some data being pointed to)
As usual, another great explanation.
Cheers!
This video reminded me of th-cam.com/video/motLOioLJfg/w-d-xo.html use of composition to delegate methods to references of other class implementations. Your series is my personal prerequisite to reading Klaus's recent book. Thank you so much for this.
Cheers! Klaus gives wonderful talks, and his new book is wonderful -- definitely recommend!