0
Array of Class Objects vs Derived Classes (C++)
Which is more efficient for program execution and/or memory consumption? I wrote a program that currently uses a 2D array of class objects (4x5 - each dimension has a specific attribute in common). Would it be better to create 5 derived classes and use 1D arrays for the other dimension? I chose the dimension with 5 elements because I will not be adding to that particular dimension, but I may add more to the dimension with 4 elements, which would require the creation of additional derived classes.
1 Odpowiedź
+ 1
For performance you want arrays over objects, in theory.