Quick Q: Pointer to class data member “::*”
▻http://isocpp.org/feeder/?FeederAction=clicked&feed=All+Posts&seed=http%3A%2F%2Fisocpp.org%2Fblog%2F2
Quick A: a pointer that lets you access the value of the member of an instance.
Recently on SO:
Pointer to class data member “::*” It’s a “pointer to member” - the following code illustrates its use: #include <iostream>
using namespace std;
class Car
public:
int speed;
;
int main()
int Car::*pSpeed = &Car::speed;
Car c1;
c1.speed = 1; // direct access
cout << “speed is” << c1.speed << endl;
c1.*pSpeed = 2; // access via pointer to member
cout << “speed is” << c1.speed << endl;
return 0;
As to why you would want to do that, well it gives you another level of indirection that can solve some tricky (...)
#News,Articles&_Books,