Click here to Skip to main content
15,904,877 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: C++ Array Of Function Pointers problem Pin
CNewbie13-Jun-05 5:39
CNewbie13-Jun-05 5:39 
GeneralRe: C++ Array Of Function Pointers problem Pin
David Crow13-Jun-05 6:08
David Crow13-Jun-05 6:08 
GeneralRe: C++ Array Of Function Pointers problem Pin
CNewbie13-Jun-05 6:16
CNewbie13-Jun-05 6:16 
GeneralRe: C++ Array Of Function Pointers problem Pin
David Crow13-Jun-05 6:27
David Crow13-Jun-05 6:27 
GeneralRe: C++ Array Of Function Pointers problem Pin
CNewbie15-Jun-05 19:32
CNewbie15-Jun-05 19:32 
GeneralRe: C++ Array Of Function Pointers problem Pin
David Crow16-Jun-05 2:56
David Crow16-Jun-05 2:56 
GeneralRe: C++ Array Of Function Pointers problem Pin
CNewbie16-Jun-05 5:30
CNewbie16-Jun-05 5:30 
GeneralRe: C++ Array Of Function Pointers problem Pin
David Crow16-Jun-05 5:43
David Crow16-Jun-05 5:43 
CNewbie wrote:
What I want to do is define the 2 function pointer arrays with the appropriate functions globally so that I can use them throughout the problem without having to redefine them each time I have to use them.

Right. The compiler is never happy when it encounters a redefinition. You can certainly make the arrays global to the entire program. However, they must be initialized within some function (e.g., main()). After that, they can be used from wherever they are needed. And, as you have already discovered, if the arrays are needed in more than one file, you'll need to employ the extern keyword. This means the arrays are visible from files other than the one in which they are defined.

CNewbie wrote:
My Class is CDialog.

Does this mean that you are not using MFC?

I'm sure you've figured this much out:

void (*call_cmd_function[160])(void);
 
void Func1( void )
{
    cout << "Func1" << endl;
}
 
void Func2( void )
{
    cout << "Func2" << endl;
}
 
void Func3( void )
{
    cout << "Func3" << endl;
}
 
void main( void )
{
    call_cmd_function[0] = Func1;
    call_cmd_function[1] = Func2;
    call_cmd_function[2] = Func3;
 
    (*call_cmd_function[2])();
    (*call_cmd_function[1])();
    (*call_cmd_function[0])();
}



"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown


GeneralRe: C++ Array Of Function Pointers problem Pin
CNewbie16-Jun-05 5:54
CNewbie16-Jun-05 5:54 
GeneralRe: C++ Array Of Function Pointers problem Pin
David Crow16-Jun-05 6:11
David Crow16-Jun-05 6:11 
GeneralRe: C++ Array Of Function Pointers problem Pin
CNewbie16-Jun-05 6:13
CNewbie16-Jun-05 6:13 
GeneralRe: C++ Array Of Function Pointers problem Pin
David Crow16-Jun-05 6:21
David Crow16-Jun-05 6:21 
GeneralRe: C++ Array Of Function Pointers problem Pin
CNewbie16-Jun-05 6:34
CNewbie16-Jun-05 6:34 
GeneralRe: C++ Array Of Function Pointers problem Pin
David Crow16-Jun-05 7:06
David Crow16-Jun-05 7:06 
GeneralRe: C++ Array Of Function Pointers problem Pin
CNewbie16-Jun-05 7:46
CNewbie16-Jun-05 7:46 
GeneralRe: C++ Array Of Function Pointers problem Pin
David Crow16-Jun-05 8:24
David Crow16-Jun-05 8:24 
GeneralRe: C++ Array Of Function Pointers problem Pin
CNewbie16-Jun-05 8:46
CNewbie16-Jun-05 8:46 
GeneralRe: C++ Array Of Function Pointers problem Pin
David Crow16-Jun-05 8:49
David Crow16-Jun-05 8:49 
GeneralRe: C++ Array Of Function Pointers problem Pin
coadtoad13-Jun-05 6:23
coadtoad13-Jun-05 6:23 
GeneralRe: C++ Array Of Function Pointers problem Pin
CNewbie13-Jun-05 11:49
CNewbie13-Jun-05 11:49 
GeneralRe: C++ Array Of Function Pointers problem Pin
coadtoad14-Jun-05 5:58
coadtoad14-Jun-05 5:58 
GeneralAccess variables in CMyView Pin
hcmuns12-Jun-05 17:26
susshcmuns12-Jun-05 17:26 
GeneralRe: Access variables in CMyView Pin
PJ Arends12-Jun-05 17:38
professionalPJ Arends12-Jun-05 17:38 
GeneralRe: Access variables in CMyView Pin
hcmuns12-Jun-05 17:49
susshcmuns12-Jun-05 17:49 
GeneralRe: Access variables in CMyView Pin
Tom Archer12-Jun-05 18:22
Tom Archer12-Jun-05 18:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.