Friday, August 12, 2011

Problem with constrcutors intialization?

the default behavior is to fire the constructors for all member objects in a class when the class is constructed. Objects declared on the bss area (global variables) are generally zero'ed out by the loader. Since you are using an int as a template argument, no constructor will be called for it. You will need to partially instantiate the template for int's if you want zero-out-on-construction behavior for that type. As an experiment, you can create a wrapper class for int that has a constructor defined which zero's out the int.

0 comments:

Post a Comment