Search code examples
c++arrayspointer-to-memberdata-members

Array of pointers to data members


class A 
{
    float m_Period; // a1
    float m_Scale;  // a2
};

I can have pointer to a data member like this:

float A::*pFloat;

For reason of handle members in cycle i need an array of such pointers. How to do this.


Solution

  • Either std::vector<float A::*> pFloats; or, if you need static initialization with the compiler counting the number of initializers, float A::*pFloat[] = {...};.