Yes, I agree. I will do a small test to figure out. But actually, I am more interested in 3 and 4. I just saw someone write similarly as 3. But in most cases, we instantiated like:
A a();
A * a = new A(1);
Not very sure how to explain what exactly a(A()) did.
OK, I try all of these. All of them are legal. So for 3, is the procedure as:
(1) A() created an instance of A.
(2) a(A()) constructed the member variable "a" using copy constructor?
Same idea for 4, but using different A constructor in step 1.
Correct. 3 creates a temporary A object with the default constructor, then uses the copy constructor to copy it to "a". This is inefficient and #1 is a better way of initializing "a" with the default constructor. #4 initializes a temporary A object with with A(int) and the uses the copy constructor to copy it to "a". #2 is a better way to initialize "a" with A(int).