What is the D equivalent of C++'s method pointers?
Tejas
notrealemail at gmail.com
Thu Jul 8 11:53:42 UTC 2021
Given a class ```Employee``` , if I have the following code
```
int (Employee::*methodPtr) () const { &Employee::getSalary };
Employee employee { "John", "Doe" };
cout << (employee.*methodPtr)() << endl;
```
What is the equivalent D code?
Ditto for pointer to class instances:
```
int (Employee::*methodPtr) () const { &Employee::getSalary };
Employee* employee { new Employee { "John", "Doe" } };
cout << (employee->*methodPtr)() << endl;
```
More information about the Digitalmars-d-learn
mailing list