#include <iostream>
using namespace std;
#define PRINT(x) cout << #x " = " << x << endl;
class Object{
public:
Object():i(5){}
int i;;
};
int main() {
Object o;
o.i = 5;
int* p = &(o.i);
PRINT(*p);
int Object::* p2m = &Object::i;
PRINT(o.*p2m);
return 0;
}
the two PRINT macros produce this:
*p = 5
o.*p2m = 5
could you tell me what the difference is between using them? when should i choose one over another? and why?
Thank you in advance!