10/2/2023 0 Comments Problem child 2 cast![]() Since the Parent class itself is abstract you wont have an object which is just a Parent object since that is not allowed and wont compile. ![]() The Parent class: The keyword abstract forces every child to implement that method, so if you have a Parent object you can safely call this method. While iterateing through that vector, I dont know which kind of child I get next (thus I cannot cast to the correct class), but due to the keyword Override of the function I call, the correct child/method is used. In the main you see a Vector 'ps' to store Parent objects, but added are Child objects which extend from the Parent. ![]() Do you really want to cast you parent into the child class? If the given Object (given as a Parent object) was created as a child class, you can access the correct functions without the cast.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |