blob: 1f24a1aa5adda0af0e7cae7f4cd93f5d074bc7db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#include <stdio.h>
struct Pure {
virtual int implme() = 0;
};
struct Parent : Pure {
virtual int getit() {
return 11;
};
int implme() { return 32; }
};
struct Child : Parent {
int getit() { return 74; }
int implme() { return 1012; }
};
struct Other {
int one() { return 11; }
int two() { return 22; }
};
int main() {
Parent *x = new Parent();
Parent *y = new Child();
printf("*%d,%d,%d,%d*\n", x->getit(), y->getit(), x->implme(), y->implme());
Other *o = new Other;
int (Other::*Ls)() = &Other::one;
printf("*%d*\n", (o->*(Ls))());
Ls = &Other::two;
printf("*%d*\n", (o->*(Ls))());
return 0;
}
|