Yola
Yola

Reputation: 19033

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.

Upvotes: 2

Views: 115

Answers (2)

James Kanze
James Kanze

Reputation: 153909

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

Upvotes: 3

Steve Jessop
Steve Jessop

Reputation: 279255

typedef float A::*member_t;

Now you can declare an array or vector of member_t.

Upvotes: 5

Related Questions