I have a master class A and a number of nested classes. For example class A may contain instances of class B, and then class B may contain instances of class C and so on. All the classes/memories will be allocated during an initialization phase (i) and then the program execution phase (ii) will follow. Will there be an advantage in the speed of the program execution phase (ii) if I minimize the use of "new" in the nested classes? For example I can use std::array since I know at compile time the sizes of the arrays I will need. However I am not sure if there is a benefit in the execution speed by doing this or whether I could simply use dynamically allocated memories inside the nested classes B,C, etc....
In other words if I had the option of either (a) only using "new" to allocate instances of class A, or (b) using "new" to allocate instances of class A and its nested subclasses as well (B,C, etc) could I expect that the runtime/execution speed of program (a), after doing the memory allocation, would be faster in C++11 compared to program (b)? Thanks
Aucun commentaire:
Enregistrer un commentaire