The following inheritance example works for the application I am working on.
The parent gets the child's data via getElement() function.
But each child has an identical copy of getElement().
I want one copy of getElement() shared by all the children.
The arrays in the Child classes are of the same type and dimensions, only the content is different.
I tried defining getElement() in the Parent class so the children would inherit getElement(), but the compiler said "error: 'array' was not declared in this scope"
Is there a way to pass data from child to parent without multiple copies of an accessor?
I understand part of what you are doing, and I certainly understand why the compiler complains. It's because the parent doesn't know anything about a child and shouldn't. You could either do this: