Exam 4 Review, Quiz 4, Convert, Aggregation+composition – Cse100 Programming With C++ 11/09

Professor object a issue instructor object issue research scientist research faculty object we could make all of those right but do you think there’s a lot of duplication that happens so like for example the code the code itself I mean not the data the code itself so maybe we have some code to set the ID of an ASU.

Employee well we should have that same code for an instructor a professor or faculty research scientist whatever all of them should be able to set the ID right so if I have a set ID.

For each one of those classes that makes it a lot harder to be able to manage for example if I need to change one of them to be to do something else on the back end don’t I have to change.

It in every other location where I have a set ID function it’s not a rhetorical question yeah I would have to change that in every single one of those places could I in principle do that yeah but do we want to know because you may you might actually forget as you’ve seen throughout this class I forget sometimes.

To update some code in some other place so that’s where inheritance is really really helpful so the upshot of all of inheritance so some students have trouble understanding inheritance sometimes so if you have a once one on one sentence summary of what inheritance actually is.

It is to reduce code duplication among classes so it’s reducing the amount of code that is shared between classes so remember the aggregation relationship what type.

Of relationship was that did we call it it was a what relationship has a relationship inheritance is a is a relationship okay so something is a something else it’s like an ASU professor.

Is an ASU employee a sophomore.

Student is an ASU student a grad student.

Is an ASU student okay so is an is a relationship here not a has a relationship okay yeah so.

It is a relationship so the way that we do this is so this is how we do it so.

We have this base class as its called so think of base as ASU employee okay so ASU employee is the base class the derived class is still is a.

Base class so you can think of derived as a issue professor or ASU faculty so an ASU faculty is an ASU employee a ASU professor is an ASU employee so in fact if we copy this code in and we can actually see.

I have ASU employee here then I better change base to ASU employee and then I change to arrive to say ASU professor I’ll change it.

To prof to make it easy then I could have another one for example which.

Is ASU research scientists for example so what this has is you may be wondering what this public has to do with it but basically what happens is anything that’s public in the ASU employee.

Class is with regard to like functions and other stuff is copied automatically for you into the the derived classes so if I have a public function here let’s just say F for example just an arbitrary function then ASU prof and this class down here automatically have the function s so I don’t have to retype that function but then you may be wondering okay well what if I wanted F to do something else in the ASU.

Prof class okay so that’s something that we’ll talk about next time so are there any last-minute questions before we go yeah it has a different meaning here yeah so no class Monday it’s Veterans.