массив указат на функ у страунстр хорошо описан, но вот как правильно
объявить его в классе? что-то не выходит, примерчик не подскажите?
Спасибо
Написал такую лабуду
======================class test {
int i;public:
test(int i);
~test() {}
void init(int);
int func1(int);
int func2(int);
int (*func[])(int);
};void
test::init(int i) {
this->i = i;
func[0] = &test::func1;
func[1] = &test::func2;
}
test::test(int i) { init(i); }int test::func1(int c) { puts("1"); }
int test::func2(int c) { puts("2"); }main()
{
test *X = new test(5);
}
//#EOFА она сволочь ругается
======================
dimfunc.c: In method `void test::init(int)':
dimfunc.c:19: converting from `int (test::*)(int)' to `int (*)(int)'
dimfunc.c:20: converting from `int (test::*)(int)' to `int (*)(int)'====================
Как объявить-то, бля?
#include <stdio.h>class test {
int i;public:
test(int i);
~test() {}
void init(int);
int func1(int);
int func2(int);
};int (test::*func[2])(int);
void
test::init(int i)
{
this->i = i;
func[0] = &test::func1;
func[1] = &test::func2;
}test::test(int i) { init(i); }
int test::func1(int c) { puts("1"); }
int test::func2(int c) { puts("2"); }main()
{
test *X = new test(5);(X->*func[0])(5);
(X->*func[1])(5);}
//#EOF