Home » C++ Programming » Functions » Question
  1. What is the output of this program?
    #include 
    using namespace std;
    class Newclass
    {
    public:
    int k;
    Newclass *operator->()
    {return this;}
    };
    int main()
    {
    Newclass object;
    object->k = 15;
    cout << object.k << " " << object->k;
    return 0;
    }
    1. 15
    2. 15 15
    3. Compilation Error
    4. Runtime Error
    5. None of these
Correct Option: B

In this program, -> operator is used to describe the member of the class and so we are getting this output.



Your comments will be displayed only after manual approval.