adplus-dvertising
frame-decoration

Question

Predict the output of the program.
class A
{
 public int i;
};
void main()
{
 A x;
 A y=x;
 x.i=10;
 y.i=20;
 y.i++;
 y.i=20;
 cout&l;<tx.i;
}

a.

10

b.

20

c.

21

d.

0

Answer: (b).20

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Predict the output of the program.

Similar Questions

Discover Related MCQs

Q. If programmer doesn’t define any copy assignment operator then ____________________

Q. Declaring a copy constructor doesn’t suppresses the compiler generated copy assignment operator.

Q. In copy constructor definition, if non const values are accepted only ________

Q. How many objects can be assigned to a single address?

Q. Use of assignment operator ____________________

Q. If more than one object refer to the same address, any changes made

Q. How to make more than one object refer to the same object?

Q. We can assign ______________________

Q. Assigning reference to an object _________________

Q. Which among the following is true ?

Q. Assigning objects takes place while passing the arguments.

Q. Which language among the following doesn’t allow pointers?

Q. Which is correct syntax for declaring pointer to object?

Q. Which operator should be used to access the members of the class using object pointer?

Q. How does compiler decide the intended object to be used, if more than one object are used?

Q. If pointer to an object is declared, ___________

Q. What is the size of object pointer?

Q. A pointer _________________

Q. Pointer to a base class can be initialized with the address of derived class, because of _________

Q. Can pointers to object access the private members of the class?