Computer Science Canada

The problem about the pointer of function and the calling of a subfunction

Author:  CHINA_yanglei [ Sun Mar 22, 2009 3:41 am ]
Post subject:  The problem about the pointer of function and the calling of a subfunction

c++:
#include <iostream>
void FileFunc();
void EditFunc();
int main()
{   
        void (*funcp)();
        funcp=FileFunc;
        (*funcp)();
        funcp=EditFunc;
        (*funcp)();

    return 0;
}
void Filefunc()
{
        std::cout<<"File function1"<<std::endl;
}
void EditFunc()
{
        std::cout<<"Edit function"<<std::endl;
}


code:
group.obj : error LNK2001: unresolved external symbol "void __cdecl FileFunc(void)" (?FileFunc@@YAXXZ)
Debug/group.exe : fatal error LNK1120: 1 unresolved externals


Thank for your advice!

Mod Edit: Remember to use syntax and code tags! Thanks Smile
code:
[syntax="cpp"]Code Here[/syntax]

Author:  cavetroll [ Sun Mar 22, 2009 10:58 am ]
Post subject:  Re: The problem about the pointer of function and the calling of a subfunction

You just made a typo on the lines

code:

void Filefunc()
{
std::cout<<"File function1"<<std::endl;
}


should be
code:

void FileFunc()
{
std::cout<<"File function1"<<std::endl;
}



That got it working for me.


: