In my code i have ints, bools, pointers and so on, i also have some type defined by me with typedef, how can i manage the default value initialization like it happens in the objects with the contrunctor?
I want to be sure that
T var;
if untouched, is always equal to my default value and i like to do this without parsing each line of code anche changing the default value manually and without using a preprocessor macro.
is this possible?
for a new typedef is possible to define a default value?
In C++11, you could write
T var{};to get value initialization to the default value.In C++03, you could write a non-POD wrapper, whose default constructor will get called by
T var;:This will allow you to safely default initialize even primitive , POD and aggregate types, which are normally left uninitialized by the
T var;declaration.