I
Immortal Nephi
My code may sound strange. I define pF inside class. pF is a pointer
to member function. You can choose one of three member function's
memory address and put it into pF. Only one member function as F() is
able to invoke pF, but you can't invoke pF inside main(). To reduce
CPU's overhead so you don't need to invoke F() and you can invoke pF
directly. Take a look at my code.
Please forgive me if you complain that my post is not wrapped with
single line. I have no control to post using Google newsgroups.
class Test
{
public:
Test() { }
~Test() {}
void F1() { pF = &Test::F2; }
void F2() { pF = &Test::F3; }
void F3() { pF = &Test::F1; }
void (Test::*pF)();
void F() { (this->*pF)(); }
};
int main(void)
{
Test test;
test.pF = &Test::F1;
test.(Test::*pF)(); // Error
test.F();
test.F();
test.F();
test.F();
return 0;
}
to member function. You can choose one of three member function's
memory address and put it into pF. Only one member function as F() is
able to invoke pF, but you can't invoke pF inside main(). To reduce
CPU's overhead so you don't need to invoke F() and you can invoke pF
directly. Take a look at my code.
Please forgive me if you complain that my post is not wrapped with
single line. I have no control to post using Google newsgroups.
class Test
{
public:
Test() { }
~Test() {}
void F1() { pF = &Test::F2; }
void F2() { pF = &Test::F3; }
void F3() { pF = &Test::F1; }
void (Test::*pF)();
void F() { (this->*pF)(); }
};
int main(void)
{
Test test;
test.pF = &Test::F1;
test.(Test::*pF)(); // Error
test.F();
test.F();
test.F();
test.F();
return 0;
}