Examveda

What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class X 
{
    public:
    int a;
	void f(int b) 
	{
		cout<< b << endl;
	}
};
int main() 
{
    int X :: *ptiptr = &X :: a;
    void (X :: * ptfptr) (int) = &X :: f;
    X xobject;
    xobject.*ptiptr = 10;
    cout << xobject.*ptiptr << endl;
    (xobject.*ptfptr) (20);
}

A. 10
20

B. 20
10

C. 20

D. 10

Answer: Option A


Join The Discussion

Related Questions on C plus plus miscellaneous

What is the difference between '++i' and 'i++' in C++?

A. None of the above

B. They both have the same effect

C. '++i' increments the value of 'i' before returning it, while 'i++' increments the value of 'i' after returning it

D. '++i' increments the value of 'i' after returning it, while 'i++' increments the value of 'i' before returning it