Which of the following represents the correct explicit call to a constructor of class A? [code] class A{ int a; public: A(int

Đức Lưu

New member
Which of the following represents the correct explicit call to a constructor of class A?
Code:
class A{
		int a;
	        public:
		A(int i)
                {
			a = i;
		}
       }
A. A a(5);
B. A a;
C. A a = A(5);
D. A a = A();
 
Answer: c
Explanation: Explicit call represents the programmer by himself mentioning the type name. So A a = A(5); is the correct explicit call as we are mentioning typename A(5) from our side, whereas A a = A(); is not the correct call because no such constructor is there in class A.
 

Tìm kiếm

Back
Top