I was under the impression that a class variable had its constructor called upon initialization of the class, and the default constructor for an integer initializes to 0. |
This actually prompted quite a discussion here in the office. Those developers who've had reason in the past to investigate in detail what the standard actually says about this tell me that, no, the "invisible" default constructor for a class will not call the pseudo-default-constructor on data members which are of built-in types.
So, the standard does
not dictate that, if you instantiate
Factoral using the compiler-created default constructor, it initialises
its_number and
its_value to 0.
However, since this is therefore undefined behaviour, it's possible that any given implementation might do that.
In any case, the variable in the OP's code we were discussing was a local variable
number which was declared in main, so the above isn't relevant anyway ;)
To the OP: it's probably better to post your updated code in a new post in the thread, rather than going back and editing your OP. It makes it easier to follow the discussions if we can see the original code that prompted those discussions.