Sams Teach Yourself C++ in 21 Days

(singke) #1
Answers 855

D


31: }
32:
33: void myClass::ShowMember()
34: {
35: cout << “itsMember: “ << itsMember << endl;
36: }
37:
38: void myClass::ShowSecond()
39: {
40: cout << “itsSecond: “ << itsSecond << endl;
41: }
42:
43: void myClass::ShowThird()
44: {
45: cout << “itsThird: “ << itsThird << endl;
46: }
47: int myClass::itsStatic = 0;
48:
49: int myClass::GetStatic()
50: {
51: return itsStatic;
52: }
53:
54: int main()
55: {
56: void (myClass::*PMF) ();
57:
58: myClass obj1;
59: PMF=myClass::ShowMember;
60: (obj1.*PMF)();
61: PMF=myClass::ShowSecond;
62: (obj1.*PMF)();
63: PMF=myClass::ShowThird;
64: (obj1.*PMF)();
65: cout << “Static: “ << myClass::GetStatic() << endl;
66:
67: myClass obj2;
68: PMF=myClass::ShowMember;
69: (obj2.*PMF)();
70: PMF=myClass::ShowSecond;
71: (obj2.*PMF)();
72: PMF=myClass::ShowThird;
73: (obj2.*PMF)();
74: cout << “Static: “ << myClass::GetStatic() << endl;
75:
76: myClass obj3;
77: PMF=myClass::ShowMember;
78: (obj3.*PMF)();
79: PMF=myClass::ShowSecond;
80: (obj3.*PMF)();
81: PMF=myClass::ShowThird;

32 0672327112_app_d.qxd 11/19/04 12:30 PM Page 855

Free download pdf