Question: Standard C++ provides a pointer-to-member mechanism for classes: Pointers to members are also permitted for subroutine members (methods), including virtual methods. How would you implement

Standard C++ provides a “pointer-to-member” mechanism for classes:

class C { public: int a; int b; } c; int C::*pm // pm points to member a of an (arbitrary)C object &C::a; C* P &c; %3D 3; // assign 3 into c.a p->*pm %3DPointers to members are also permitted for subroutine members (methods), including virtual methods. How would you implement pointers to virtual methods in the presence of C++-style multiple inheritance?

class C { public: int a; int b; } c; int C::*pm // pm points to member a of an (arbitrary)C object &C::a; C* P &c; %3D 3; // assign 3 into c.a p->*pm %3D

Step by Step Solution

3.43 Rating (150 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

In C pointers to virtual methods are implemented using a mechanism called the virtual function table ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Language Pragmatics Questions!