Most answers so far say that you're not calling a constructor. You're seeing the output of the constructor call. So just disregard those answers that are denying reality by over-simplifying.
The code snippet
if(b_ == 10) {
A();
}
creates and destroys a temporary object of class A
.
As part of the creation the A
default constructor is called to initialize the object.
The C++98 rules are designed to ensure that unless you use very low level functionality to impose your contrary will, every creation of an object of type T
corresponds to exactly one T
constructor call on that object. And vice versa, if you call a T
constructor (which is another valid view of the above code) then, in C++98, you're creating a T
object. You can call that the C++ constructor call guarantee: creation = constructor call.
The constructor call guarantee means, among other things, that a constructor call failure is an object creation failure: if a constructor fails, then you don't have an object.
Which simplifies things a lot.
For example, it says that if you do new A
, and the A
default constructor fails, then you don't have an object. So the memory that was allocated to hold that object, is automatically deallocated. And so that expression does not leak memory even if the object construction fails -- instead of an object, you just get an exception.
It's almost beautiful. :-)