Timeline for Polymorphism with overrides and base calls simulating an employee
Current License: CC BY-SA 3.0
17 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 6, 2018 at 11:29 | comment | added | Pablo | do I need to free existing super ... before assignin? Once again, I've told you 100 times, you cannot free something and then try to access the content later. | |
Mar 6, 2018 at 11:26 | comment | added | Pablo |
@App2015 no, why are you insisting on freeing stuff in the create function that are needed throughout the object's life span? In order to have a correct override mechanism, you need the original object with the original function pointers which you access with self->base . Only when the whole Employee object is destroyed you can free the base object. And I told you 100 times already (but you keep ignoring that), free(&employee->super) is simply wrong, because you can only pass to free the address that you've got from malloc . See my example in edit 3 on how to do it.
|
|
Mar 6, 2018 at 9:19 | comment | added | App2015 |
ok, In my code, within Employee_new function, do I need to free existing superfree(&employee->super) before assigning employee->super = *Person_new(first, last); to release the auto allocated sub struct value as a result of malloc on the parent struct. If not then why?
|
|
Mar 5, 2018 at 14:20 | comment | added | Pablo | @App2015 no, I'm not going to do that, if you have further question with changes of your new code, please create a new question with the new code, then I'll gladly take a look at that. See What should I do when someone answers my question? | |
Mar 5, 2018 at 8:54 | comment | added | yuri | "There is one thing I don't line about" You probably mean like about? | |
Mar 5, 2018 at 7:16 | vote | accept | App2015 | ||
Mar 5, 2018 at 4:43 | comment | added | App2015 | Thanks Pablo. I liked the fact that you have valgrind, I couldn't have it on Mac. one last favor can you download this and review if everything is intact, I've spent a great deal on this to get it right, also would you like to discuss if this is runtime or compile time polymorphism? Download: dropbox.com/s/q4vdpicj1aq17ao/Polymorphism.zip?dl=0 | |
Mar 5, 2018 at 4:34 | comment | added | Pablo | @App2015 yes, your approach was correct, I didn't realize it right away, I had to step through the code with the debugger. | |
Mar 5, 2018 at 4:32 | comment | added | App2015 | I read your edit3, in other words are you saying that my original approach was correct? I'm confused a bit going in both directions now | |
Mar 5, 2018 at 2:58 | history | edited | Pablo | CC BY-SA 3.0 |
added 3534 characters in body
|
Mar 5, 2018 at 2:20 | history | edited | Pablo | CC BY-SA 3.0 |
added 55 characters in body
|
S Mar 5, 2018 at 2:03 | history | edited | Pablo | CC BY-SA 3.0 |
added 4065 characters in body
|
Mar 5, 2018 at 1:48 | review | Suggested edits | |||
S Mar 5, 2018 at 2:03 | |||||
Mar 5, 2018 at 1:19 | comment | added | App2015 | Let us continue this discussion in chat. | |
Mar 5, 2018 at 0:56 | history | edited | Pablo | CC BY-SA 3.0 |
added 1515 characters in body
|
Mar 5, 2018 at 0:41 | review | First posts | |||
Mar 5, 2018 at 0:45 | |||||
Mar 5, 2018 at 0:37 | history | answered | Pablo | CC BY-SA 3.0 |