Multiple choice

Consider the following C++ code: class Name{ int x,y; public: Name(int a, b=10) { x=a; }};

If an object of this class is created as Name obj1(100); then what would be the values assigned to x and y?

  1. 100 and 10

  2. 100 and 200

  3. 10 and 100

  4. 200 and 100

  5. No values are assigned.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

This is correct assignment as with the object creation, only one argument is passed and another value assigned is the default argument.