Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /////
- // С++ операторы Делегирования полей класса и методов (->* / .*)
- ///
- struct A
- {
- int n1 = 44;
- int n2 = 55;
- int foo1() { return n1; }
- int foo2() { return n2; }
- };
- void main()
- {
- A a;
- int A::*ptN = &A::n1;
- cout << a.*ptN << endl;
- ptN = &A::n2;
- cout << a.*ptN << endl;
- int (A::*ptF)() = &A::foo1;
- cout << (a.*ptF)() << endl;
- ptF = &A::foo2;
- cout << (a.*ptF)() << endl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement