Show: Delphi
C++
Display Preferences
Talk:Binary Operators
From RAD Studio
The section on the Pointer-to-Member operators are probably best explained with an example. Here's one that you could use:
#include <iostream> class TFoo { public: void func() { std::cout << __func__ << std::endl; } int data; }; void (TFoo::*pmfn)() = &TFoo::func; int TFoo::*pmd = &TFoo::data; int main() { TFoo foo; TFoo *pfoo = &foo; // Call func with foo/pfoo (foo.*pmfn)(); // With object (pfoo->*pmfn)(); // With pointer // Set/read data with object and ptr respectively foo.*pmd = 123; std::cout << "data=" << pfoo->*pmd << std::endl; return 0; }
Response
Thank you for your review comment and code example. I have added the code example to the topic.
KrisHouser 07:55, 26 March 2012 (PDT)