I
Immortal Nephi
I always think about pointer to member function array. Now, I think
about pointer to data member array. Compare both. Let me know what
you think. The data members are like colors. The data member array
needs to access data members directly. If you change the color, then
data member array receive new colors. My code is ideal for font
image. The colors are like foreground and background.
You can see my code for curiousity.
class Test
{
public:
Test() : a( 1 ), b( 2 ), c( 3 )
{
}
~Test() {}
void dosomething()
{
( this->*pF[ 0 ] )();
const int d = this->*rgData[ 0 ];
const int d2 = this->*rgData[ 1 ];
const int d3 = this->*rgData[ 2 ];
a += 2;
b += 2;
c += 2;
const int d4 = this->*rgData[ 0 ];
const int d5 = this->*rgData[ 1 ];
const int d6 = this->*rgData[ 2 ];
}
private:
void RunA() {}
void RunB() {}
void RunC() {}
static void ( Test::* const pF[ 3 ] )();
int a;
int b;
int c;
static const int Test::*rgData[ 3 ];
};
void ( Test::* const Test:F[ 3 ] )() = { &Test::RunA, &Test::RunB,
&Test::RunC };
const int Test::* Test::rgData[ 3 ] = { &Test::a, &Test::b,
&Test::c };
int main()
{
Test t;
t.dosomething();
return 0;
}
about pointer to data member array. Compare both. Let me know what
you think. The data members are like colors. The data member array
needs to access data members directly. If you change the color, then
data member array receive new colors. My code is ideal for font
image. The colors are like foreground and background.
You can see my code for curiousity.
class Test
{
public:
Test() : a( 1 ), b( 2 ), c( 3 )
{
}
~Test() {}
void dosomething()
{
( this->*pF[ 0 ] )();
const int d = this->*rgData[ 0 ];
const int d2 = this->*rgData[ 1 ];
const int d3 = this->*rgData[ 2 ];
a += 2;
b += 2;
c += 2;
const int d4 = this->*rgData[ 0 ];
const int d5 = this->*rgData[ 1 ];
const int d6 = this->*rgData[ 2 ];
}
private:
void RunA() {}
void RunB() {}
void RunC() {}
static void ( Test::* const pF[ 3 ] )();
int a;
int b;
int c;
static const int Test::*rgData[ 3 ];
};
void ( Test::* const Test:F[ 3 ] )() = { &Test::RunA, &Test::RunB,
&Test::RunC };
const int Test::* Test::rgData[ 3 ] = { &Test::a, &Test::b,
&Test::c };
int main()
{
Test t;
t.dosomething();
return 0;
}