Your class has two constructors and you are watching only one of them. std::vector
creates its elements by copy-constructing them from the original element you supplied. For that purpose, the copy-constructor of class A
is called 5 times in your example.
The copy-constructor for A
in your example is implicitly declared and defined by the compiler. If you so desire, you can declare and define it yourself. If you print something from it, you will see that it is called at least 5 times.