[Dev-C++] Re: Problem with function pointer inside a class
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <cg...@wo...> - 2002-12-27 19:33:28
|
>typedef void (classname::*funny)(void**); //I tried either void > >Well it depends on what arguments you want. All them are void func(void**); The comment is continued in the next line, I forgot taking into account the posible wrapping of the text. Anyway I know the alternative I was citing is wrong. >funny *function; OR funny function[19]; > >funny is a pointer to function type so if you want an array of >pointers to functions on the free store, you must use the "funny >*function" stuff. funny *function stuff? Does it means say funny *function; and then function = new funny[number]? I do it. (No spam) >Then inside another function: >int cuantos = rand() % 19; >(this->*function[cuantos])(NULL); >NULL is deprecated in C++. Also you forgot some parenthesis. You should do: > >(this->*classname::function[cuantos])(0); The parenthesis are there. I didn't say all functions are private. I used the modifications you pointed, still access violation, when calling the function. ... cout << "Here!" << endl; (this->*(classname::)cion[index])(param); ... The output: ... Here! Program.exe has generated errors, it will be closed by windows, you'll have to restart it. I tried some compiler options (-vtable-gc, and other) but no resul. |