devxlogo

Arrays of Pointers to Members

Arrays of Pointers to Members

You can create an array of pointers to member just as you would create arrays of any other type. The following example creates an array of pointers to member functions of class Parrot and initializes its elements with the addresses of Parrot’s member functions:

 class Parrot{public: void Speak() const; void Fly() const;};typedef void (Parrot::*PMF)() const;// create arrayPMF funcs[2]={&Parrot::Speak, &Parrot::Fly};

size=3>

devx-admin

Share the Post: