-
Why choose to use pointers for inheritance? |
Beta Was this translation helpful? Give feedback.
Answered by
c-white
Jul 25, 2024
Replies: 1 comment 4 replies
-
Can you elaborate and point to examples? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The code has some inheritance in the object-oriented sense, but most of the pointers you see aren't really serving the same purpose. Rather, they are nested containers, where one container might hold multiple things, and if a subcontainer wants to change some parameter in its parent, it should do so in a way that propagates to all other subcontainers.
Consider the
MeshBlock
class insrc/mesh/mesh.hpp
. EachMeshBlock
object stores all the information for a chunk of the domain. This includes coordinates and their associated routines (encapsulated in aCoordinates
object), hydrodynamical variables and their associated routines (encapsulated in aHydro
object), electromagnetic fields and thei…