C++: Pointer to class data member - Stack Overflow

C++: Pointer to class data member - Stack Overflow

瀏覽:1072
日期:2025-04-25
I came across this strange code snippet which compiles fine: class Car { public: int speed; }; int main() { int Car::*pSpeed = &Car::speed; return 0; } Why does C++ have this pointer to a non-static data member of a class? What is the use of this strange ...看更多