I don’t know why this is driving me nuts but it is. I have a function defined and forward declared in main.
static void myFunc(int x);
static void myFunc( int x)
{
//do stuff
}
main()
I want to use myFunc(int x) in another class. So I would think all I have to do is
extern static void myFunc(int x) within that classes header and then just call it where I need to in the class definition, but it won’t work.
What am I doing wrong?
Thanks
You cannot use extern and static together they are mutually exclusive.
staticmeans Internal Linkageexternmeans External LinkageYou need to use only
externif you need External Linkage.Good Read:
what is external linkage and internal linkage in c++?