adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    using namespace std;
    class Testpm 
    {
        public:
        void m_func1() 
        { 
            cout << "func1\n";
        }
        int m_num;
    };
    void (Testpm :: *pmfn)() = &Testpm :: m_func1;
    int Testpm :: *pmd = &Testpm :: m_num;
    int main() 
    {
        Testpm ATestpm;
        Testpm *pTestpm = new Testpm;
        (ATestpm.*pmfn)();
        (pTestpm ->* pmfn)();
        ATestpm.*pmd = 1;
        pTestpm ->* pmd = 2;
        cout << ATestpm.*pmd << endl
        << pTestpm ->* pmd << endl;
    }

a.

func1

b.

func1 func1

c.

1 2

d.

func1 func1 1 2

Answer: (d).func1 func1 1 2

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?