Multiple choice

Consider the following C++ code:

class Sample {
    int a;

public:
    Sample(int b)
    {
        a = b;
    }
    Sample(Sample s)
    {
        a = s.a;
    }
};
void main()
{
    Sample s(100);
    Sample s1(s);
}

Referring to the above program code, what initialises the object s1?

  1. 1000

  2. Value of s object

  3. 200

  4. 300

  5. 400

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

This is the correct option.