8 Templated(T aval
) : val(aval
) {
9 cout
<< __func__
<< " Ctor" << endl
;
12 cout
<< __func__
<< " Dtor" << endl
;
15 cout
<< __func__
<< " val=" << val
<< endl
;
17 virtual void PrintName(int,int) const {
18 cout
<< __func__
<< endl
;
22 struct MostDerived
: Templated
<int>, Templated
<double>
24 MostDerived() : Templated
<int>(12), Templated
<double>(3.14) {
25 cout
<< "MostDerived Ctor" << endl
;
28 cout
<< "MostDerived Dtor" << endl
;
31 Templated
<int>::PrintV();
32 Templated
<double>::PrintV();
34 virtual void PrintName(int,int) const {
35 cout
<< __func__
<< endl
;
43 // test "this adjustment"
44 void (Templated
<int>::*pmf1
)();
45 void (Templated
<double>::*pmf2
)();
46 void (MostDerived::*pmf3
)();
47 void (MostDerived::*pmf4
)(int,int) const;
48 pmf1
= static_cast<void (Templated
<int>::*)()>(&MostDerived::PrintV
);
49 // the following has a non-trivial "this adjustment"
50 pmf2
= static_cast<void (Templated
<double>::*)()>(&MostDerived::PrintV
);
51 pmf3
= &Templated
<double>::PrintV
;
52 pmf4
= &Templated
<double>::PrintName
;
55 (bothobj
.*pmf4
)(2, -5);