C++ When will be allocated memory in new object? -


i want write class, can hold 9 variables (physcial values). 5 of should there every time, want control other 4 flag (optional).

my question is: if have 4 variables in private sector of class not use... allocated memory these? if yes: how can avoid it?

i want allocate memory optional variables dynamic.

for 4 variables, need declare member variables pointers initialized nulls in constructors. allocate , deallocate upon need, don't forget surelly deallocate upon class descrution. however, if intention memory gain, need evaluate sizeof of variables against sizeof of pointers them whether benefitial. has sense complex large data types, or not expose header files. in 32-bit platforms, 4 variables require 4*4=16 bytes pointers, when not used. plus memory consuming content pointers point when used.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -