Home » C++ Programming » Classes & Objects » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    class Example
    {
    public:
    Example()
    {
    cout << "N::N()" << endl;
    }
    Example( Example const & )
    {
    cout << "N::N( N const & )" << endl;
    }
    Example& operator=( Example const & )
    {
    cout << "N::operator=(N const &)" << endl;
    }
    };
    Example function()
    {
    Example temp;
    return temp;
    }
    int main()
    {
    Example p = function();
    return 0;
    }
    1. N::N(N const & )
    2. N
    3. N::operator=(N const &)
    4. N::N()
    5. None of these
Correct Option: D

As we are passing the object without any attributes it will return as N::N().



Your comments will be displayed only after manual approval.