ExamVeda
Login
Home
C plus plus miscellaneous
?

What will be the output of the following C++ code?
#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;
}

Answer & Solution
Correct Answer: Option D
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.