The tutorial you are reading makes some serious terminological distortions/simplifications. The statement saying that
T tSum = T();
calls "default constructor" is incorrect. It is immediately obvious from the fact that in general case type T
can easily be a non-class type. Non-class types don't have any constructors, yet the above initialization is valid for them as well.
The proper term in this case is value-initialization. Expression T()
produces a temporary object of type T
initialized by value-initialization process. Value-initialization works in accordance with its own specific rules, and it does not necessarily involve any constructors at all. It proceeds in completely constructor-less ways for non-class types as well as for some categories of class types.
For example, expression int()
produces value 0
of type int
- that is what value-initialization means for type int
(and for all scalar types). It, of course, does not involve any "default constructors", since type int
can't possibly have any constructors.
Again, expression T()
in not a constructor call, as that tutorial seems to incorrectly state. Expression T()
is actually a functional-style cast with no operand. A functional-style cast with no operand produces, as I said above, a value-initialized temporary object of type T
. It does not depend on the constructor "returning" anything.
The temporary value if T()
expression is then used as initializer for tSum
object. This syntax invokes copy initialization of tSum
from T()
.