Problem: I need an array (datamember) in a parent class A.
However, depending on the child class, that array should have a different number of elements.
Is this possible?
If yes, how can I do this? (without dynamic allocation)
If no, then is there any way around? (without dynamic allocation)
Thanks
It depends on how you plan on using said parent class, but you can accomplish what you’ve described using templates.
This has many limitations (such as being unable to use a Parent class pointer really), but it avoids having the dynamic allocation.
EDIT — Since you need true access to a parent array, here is an alternative.