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};

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist