Nguyễn Hồng Yến
New member
What will be the output of the following C++ code?
A. func1
B.
func1
func1
C.
1
2
D.
func1
func1
1
2
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;
}
B.
func1
func1
C.
1
2
D.
func1
func1
1
2