Home » C++ Programming » Classes & Objects » Question
  1. What is the output of this program?
    #include 
    using namespace std;
    class DummyClass
    {
    public:
    int IsItMe (DummyClass& parameter);
    };
    int DummyClass::IsItMe (DummyClass& parameter)
    {
    if (¶meter == this)
    return true;
    else
    return false;
    }
    int main ()
    {
    DummyClass p;
    DummyClass *q = &p;
    if (q->IsItMe(p))
    {
    cout << "Program executed...";
    }
    else
    {
    cout<<"Program not execute...";
    }
    return 0;
    }
    1. Program not execute...
    2. Program executed...
    3. Compilation Error
    4. Runtime Error
    5. Garbage Value
Correct Option: B

In this program, we are just pointing the pointer to a object and printing execute if it is correctly pointed.



Your comments will be displayed only after manual approval.