#include <iostream>
using namespace std;
class X{
public:
int p;
};
int main(){
int b;
X obj;
int X::*ptr = &X::p;
obj.p = 100;
cout<<obj.p<<endl;
cout<<ptr<<endl;
cout<<obj.*ptr<<endl;
system("pause");
return 0;
}
When i run this program, i get the output as:
100
1
100.
I understand why it shows 100...but what i do not understand is that why does cout<<ptr<,endl outputs 1. Isn't it should be pointing the address of variable p? Thanks a lot!!