adplus-dvertising
frame-decoration

Question

Which constructor will be called from the object obj2 in the following program?
class A
{
 int i;
 A()
 {  
  i=0;  
 }
 A(int x)
 {  
  i=x+1;  
 }
 A(int y, int x)
 {  
  i=x+y;  
 }
};
A obj1(10);
A obj2(10,20);
A obj3;

a.

A(int x)

b.

A(int y)

c.

A(int y, int x)

d.

A(int y; int x)

Answer: (c).A(int y, int x)

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Which constructor will be called from the object obj2 in the following program?