adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    using namespace std;
    class sample
    {
        public:
        sample() 
        {  
            cout << "X::X()" << endl; 
        }
        sample( sample const & ) 
        {  
            cout << "X::X( X const & )" << endl;
        }
        sample& operator=( sample const & )
        { 
            cout << "X::operator=(X const &)" << endl;
        }
    };
    sample f() 
    {
        sample tmp;
        return tmp;
    }
    int main() 
    {
        sample x = f();
        return 0;
    }

a.

X::operator=(X const &)

b.

X::X( X const & )

c.

X::X()

d.

None of the mentioned

Answer: (c).X::X()

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?